📜 ⬆️ ⬇️

Multiple sites on the same CakePHP engine

So. I explain popularly. For he figured it out so far spent not 10 minutes. We make an example of a conventional site " Travel ".




Configuration.


Everything is simple (as it turned out). Open the file /var/www/travel/index.php and edit the following block (comments are deleted):
if (!defined('ROOT')) {
define('ROOT', dirname(dirname(dirname(__FILE__))));
}

if (!defined('APP_DIR')) {
define('APP_DIR', basename(dirname(dirname(__FILE__))));
}

if (!defined('CAKE_CORE_INCLUDE_PATH')) {
define('CAKE_CORE_INCLUDE_PATH', ROOT);
}

what would it look like this:
// (!) apache wwwroot
if (!defined('ROOT')) {
define('ROOT', DS . 'var' . DS . 'www');
}

// (!)
if (!defined('APP_DIR')) {
define('APP_DIR', 'travel.app');
}

// (!)
if (!defined('CAKE_CORE_INCLUDE_PATH')) {
define('CAKE_CORE_INCLUDE_PATH', DS . 'var' . DS . 'www' . DS . 'cake.core');
}

')
Now we write localhost / travel in the browser and see the test screen CakePHP, in which we are told that everything is connected and working.

Accordingly, for new sites, we make copies of / travel and /travel.app (or everything from the very beginning from the “clean” cakePHP), set up /travel/index.php and rejoice at the result.

PS Yes, yes, this is basically a translation of a piece of cakePHP manual, but either I'm stupid or it’s crooked, but I had to suffer a little to get what I got. And yes, cakePHP I study only a few hours, so do not judge strictly.
By the way, if there are cakePHP experienced or novice users, then I would be very happy to make contact with you, because it is easier and faster together.

Source: https://habr.com/ru/post/16320/


All Articles