1

The Situation

Currently, there are two separate cakePHP projects(apps) where implementation is done and running smoothly of course with different database.

Now, the requirement is to merge these two separate cakePHP apps into one with same database and to run on different domains.

The Problem

1)There exists two different login functions which should be one after merging.Like this there may be some other huge code should be written common.

So, please provide solution or direct me to right way how can one manage common code for multiple apps with different domain

e.g., https://www.sample-1.com/login and https://www.sample-2.com/login which is using same database to validate users.

2) How to distinguish routes? 3) How to manage such projects which will grow later?

1 Answers1

0

For both domian you may call common database file and common app folder. Then you can switch database depends upon request action

Try this

 if (isset($_SERVER) && isset($_SERVER['SERVER_NAME'])) {
   if (strpos($_SERVER['SERVER_NAME'], 'localhost') === false) {
    $config = ConnectionManager::getDataSource('defaultCompany')->config;
  }        
}

inside database.php file

var $defaultCompany = array(
    'driver' => 'mysql',
    'persistent' => false,
    'encoding' => 'utf8',
    'host' => 'localhost',
    'login' => '',
    'password' => '',
    'database' => '',
    'prefix' => '',
    'port' => '',
);

Or if you want common file in both domain. Create plugins outside app folder directory and put inside it.

Sudhir
  • 835
  • 11
  • 31