Page contents


Once your application is complete, or even before that you’ll want to deploy it. There are a few things you should do when deploying a CakePHP application.

Check your security

If you’re throwing your application out into the wild, it’s a good idea to make sure it doesn’t have any leaks. Check the Security to guard against CSRF attacks, form field tampering, and others. Doing Data Validation, and/or Data Sanitization is also a great idea, for protecting your database and also against XSS attacks. Check that only your webroot directory should be publicly visible, and that your secrets (such as your app salt, and any security keys) are private and unique as well!

Set document root

Setting the document root correctly on your application is an important step to keeping your code secure and your application safer. CakePHP applications, should have the document root set to the application’s app/webroot. This makes the application and configuration files inaccessible through a URL. Setting the document root is different for different webservers. See the Advanced Installation documentation for webserver specific information.

Update core.php

Updating core.php, specifically the value of debug is extremely important. Turning debug = 0 disables a number of development features that should never be exposed to internet at large. Disabling debug changes the following types of things:

  • Debug messages, created with pr() and debug() are disabled.
  • Core CakePHP caches are flushed every 99 years, instead of every 10 seconds as in development.
  • Error views are less informative, and give generic error messages instead.
  • Errors are not displayed.
  • Exception stack traces are disabled.

In addition to the above, many plugins and application extensions use debug to modify their behavior.

Multiple CakePHP applications using the same core

There are a few ways you can configure multiple applications to use the same CakePHP core. You can either use PHP’s include_path or set the CAKE_CORE_INCLUDE_PATH in your application’s webroot/index.php. Generally using PHP’s include_path is easier and more robust. CakePHP comes preconfigured to look on the include_path as well so it’s simple to use.

In your php.ini file locate the existing include_path directive, and either append to it or add an include_path directive:

include_path = '.:/usr/share/php:/usr/share/cakephp-2.0/lib'

This assumes you are running a *nix server, and have CakePHP in /usr/share/cakephp-2.0.