Separating CakePHP App from Core.
Why would I do that?
-Easy to upgrade
-Easy to deploy new apps
-App isolation from Core
These steps should be fairly straight forward and easy to follow. The way we set it up puts the core in the root, so this will be good for local installations on mac/linux. You can set it up for a shared environment, but I will leave that for another day.
Note: This is showing CakePHP 2.1.1 but the steps are the same for later versions.
Step 1 - Download core and place files in the proper folders.
Make the initial directories. The first is what we will connect our App’s to. The second will contain the core itself.
mkdir /var/cake
mkdir ~/CoreCode
cd ~/CoreCode
wget <a href="https://github.com/cakephp/cakephp/tarball/2.1.1" target="_blank">https://github.com/cakephp/cakephp/tarball/2.1.1</a><br />
tar -zxvf<br />
mv cakephp-cakephp-0cad237 cakephp-2.1.1
cd /var/cake
ln -sfn ~/CoreCode/cakephp-2.1.1/ cakephp2
cd ~/CakeCore/cakephp-2.1.1
cp -av App ~/public_html/
Step 3 - Configure the application to the core
This is clearly the most important step. Change the Keys and connect to the database. This is normal and won’t be covered. What is different is now we will link our App to our Core. Navigate to App/Webroot and open index.php Uncomment the following line:
<?
//define('CAKE_CORE_INCLUDE_PATH', ROOT . DS . 'lib');
<?
define('CAKE_CORE_INCLUDE_PATH', DS.'var'.DS.'cake'.DS.'cakephp2'.DS.'lib');
We should be all configured and setup now to connect properly to our core. We can repeat this step as needed. You can also download this awesome start app which includes Twitter Bootstrap (a killer CSS library) and jQuery.
Click here to download the starter app.