The Magento compiler will cleverly merge the 100's of Magento files into a small handful of files. This can make loading the Magento framework a little quicker and a little less memory intensive, which can have a small impact on the speed of your site. For truly impressive speeds, considering installing a Magento full page cache extension.
The merging of files is great for a live site but this can cause errors when making code changes. The most common causes of compiler errors are:
- Installing or uninstalling an extension with the compiler enabled
- Disabling the compiler before installing an extension but enabling it again afterwards rather than re-compiling first.
If you are going to use the compiler, always disable the compiler before making any changes to your code (including installing and uninstalling extensions). After making the changes, always re-compile it by clicking either the 'Run Compliation Process' or 'Re-Compile' button. After re-compiling, you can then enable the compiler again.
If you're reading this though, the above information is useless as the error has already occured and probably locked you out of your Admin. Remember this information for future reference though and avoid this situation again.
Identify a Magento Compiler Error
The easiest way to determine whether you have a Magento compiler error is to examine the error message. Any error message that includes the path '/includes/src/' is always a compiler error as the /includes/src/ directory is where Magento stores the compiled files.
Fixing a Compiler Error
Fortunately the compiler is quite easy to manually disable. This will resolve the compiler issue and allow you to access your Magento Admin so that you can re-compile before enabling the compiler again.
Access your Magento website using FTP and open the file /includes/config.php. You should see the following code:
define('COMPILER_INCLUDE_PATH', dirname(__FILE__).DIRECTORY_SEPARATOR.'src'); define('COMPILER_COLLECT_PATH', dirname(__FILE__).DIRECTORY_SEPARATOR.'stat');
This code tells Magento where to look for the compiled files. To disable the compiler, simply comment out these lines (add a '#' character to the start of each line). The result should look like the following:
#define('COMPILER_INCLUDE_PATH', dirname(__FILE__).DIRECTORY_SEPARATOR.'src'); #define('COMPILER_COLLECT_PATH', dirname(__FILE__).DIRECTORY_SEPARATOR.'stat');
You should now be able to access your Magento Admin again and re-compile the files. After this, feel free to enable the Magento compiler again.