
Multiple sites on the same CakePHP engine
So. Explain popularly. For he himself figured out spent 10 minutes. We make on the example of the conditional site " Travel ".
Everything is simple (as it turned out). Open the file /var/www/travel/index.php and edit the following block (comments are deleted): so that it looks like this: Now in the browser we write localhost / travel and we see the CakePHP test screen, in which we are told that everything is connected to us and working. Accordingly, for new sites, we make copies of / travel and /travel.app (or everything from the very beginning from the “clean” cakePHP), configure /travel/index.php and enjoy the result. PS Yes, yes, this is basically a translation of a piece of cakePHP manual, but either I'm stupid or it's written crookedly, but I had to suffer a bit to get what happened. And yes, cakePHP I only study a few hours, so do not judge strictly.
By the way, if there are experienced or novice cakePHP users here, then I would be very happy to contact you, because together it’s easier and faster.
- The engine is the CakePHP [ cakephp / cake and cakephp / vendors ] I suffered (!) In /var/www/cake.core (/ var / www I have apache wwwroot) - that is, the engine will be used for all projects, and will not change until the next version of CakePHP.
- Content cakephp / app / webroot tolerated (!) In / var / www / travel (in this folder we have all the css, images, js, uploads, etc.)
- All of cakephp / the app (no longer there webroot, we last step from there moved) carry over (!) In /var/www/travel.app (there we will have all the logic and templates. The MVC that is).
Configuration.
Everything is simple (as it turned out). Open the file /var/www/travel/index.php and edit the following block (comments are deleted): so that it looks like this: Now in the browser we write localhost / travel and we see the CakePHP test screen, in which we are told that everything is connected to us and working. Accordingly, for new sites, we make copies of / travel and /travel.app (or everything from the very beginning from the “clean” cakePHP), configure /travel/index.php and enjoy the result. PS Yes, yes, this is basically a translation of a piece of cakePHP manual, but either I'm stupid or it's written crookedly, but I had to suffer a bit to get what happened. And yes, cakePHP I only study a few hours, so do not judge strictly.
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);
}
// Тут просто указываем полный(!) путь до 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');
}
By the way, if there are experienced or novice cakePHP users here, then I would be very happy to contact you, because together it’s easier and faster.