How to share CakePHP 2.1 core for multiple apps?

CakePHP 2.1  allows you to use one set of core files while maintaining multiple applications.
Make sure the host is pointing to the correct directory like /var/www/Sites/app/webroot/. Verify mod_rewrite is in fact on. Enable mod_rewrite with: a2enmod rewrite.
Set up the .htaccess files in the /var/www/Sites/app/ and the /var/www/Sites/app/webroot directories.
The directory /var/www/frameworks/cakephp2.1 contains the core.

1. Change the following constants in /var/www/Sites/index.php:

if (!defined('CAKE_CORE_INCLUDE_PATH')) {
 //OLD: define('CAKE_CORE_INCLUDE_PATH', ROOT . DS . 'lib');
   define('CAKE_CORE_INCLUDE_PATH', DS.'var'.DS.'www'.DS.'frameworks'.DS.'cakephp2.1'.DS.'lib');

2. Do changes in /var/www/Sites/app/webroot/index.php:

if (!defined('CAKE_CORE_INCLUDE_PATH')) {
  if (function_exists('ini_set')) {
 //ini_set('include_path', ROOT . DS . 'lib' . PATH_SEPARATOR . ini_get('include_path'));
 ini_set('include_path', DS.'var'.DS.'www'.DS.'frameworks'.DS.'cakephp2.0.6'.DS.'lib'. PATH_SEPARATOR . ini_get('include_path'));

As you can find same goes for plugins and vendors folder.
You can have only one cake core but you must have one app folder (containing MVC) by site.

Happy Coding!

This entry was posted in cakePHP 2.1 and tagged , , , . Bookmark the permalink.