How to enable compilation in Magento using the command line tool

The compiler in Magento makes a copy of every class used by the Magento system in the directory “includes/src” using the full class name as the filename. Thus, Magento Autoloader has to look only in the directory “includes/src” instead of traversing multiple paths.

Magento ships with a command line script “compiler.php” located in the shell directory present at the {{MAGENTO_ROOT}} of you installation.

To use this tool open the terminal window and “cd” to the “shell” directory.

cd [MAGENTO_ROOT]/shell/

To see what all you can do with this tool, run the following command:

php -f compiler.php help

To enable compilation run the following command

php -f compiler.php compile

To disable compilation run the following command

php -f compiler.php disable

When you enable the compilation, the following two lines in the file {{MAGENTO_ROOT}}/includes/config.php get uncommented automatically while on disabling the compilation the lines are commented.


This config.php file is included in  {{MAGENTO_ROOT}}/index.php file as shown below:

* Compilation includes configuration file
define('MAGENTO_ROOT', getcwd());

$compilerConfig = MAGENTO_ROOT . '/includes/config.php';
if (file_exists($compilerConfig)) {
include $compilerConfig;

Disabling the compilation does not delete the compiled files from the directory “includes/src”. To delete the compiled files, run the following command

php -f compiler.php clear

To check the compilation status run

php -f compiler.php state



  1. In order to use this tool, the directory {MAGENTO_ROOT}}/includes and the file {MAGENTO_ROOT}}/includes/config.php must both be writeable.
  2. Before you make any changes to your Magento installation you should always disable compilation. Once the changes are made, run the compilation process, and then enable it.

Leave a Comment

Back to top