Development Configuration File
CS-Cart allows you to create a separate configuration file where you can specify settings without modifying config.local.php. This file is called local_conf.php.
To configure CS-Cart for development, complete the steps below:
Create local_conf.php in the root directory of your installation.
Open local_conf.php and add the following code to it:
You can limit the settings you specify in local_conf.php to a certain IP. That is useful if you work on a live store: that way only you would see the error messages and the debugger.
The IP restrictions are added with the following part of the code:
CS-Cart has a built-in debugger that shows:
- Server and PHP settings.
- The list of SQL queries during the opening of the current page.
- The templates that were used for building the page.
- Request parameters.
- The time and memory used for opening the page.
To access the debugger, go to the Administration panel and add the
debug parameter to the URL, so that it would look like this:
The bug icon will appear in the top right corner of the page. Click it to open and close the debugger sidebar. Alternatively, you can hit
Ctrl + Alt + D.
To keep the debugger enabled both on the storefront and in the administration panel at all times, uncomment the following line in local_conf.php:
When you write PHP code, a Smarty template or an SQL query, mistakes might happen. Usually Smarty and PHP errors result in a blank page. A database error caused by a wrong SQL query will result in the following message: SERVICE UNAVAILABLE. Sorry, service is temporarily unavailable.
To see the actual error messages, use Development Mode. You can enable it in local_conf.php with the following line:
Now, if something goes wrong, you should see an error message with the path to the file that caused the error.
Development Mode has another useful feature for add-on developers.
CS-Cart stores the CSS and TPL files of the installed add-ons in the design/themes directory. Normally CS-Cart deletes these files when the add-on is uninstalled. If the add-on is installed again, these files are taken from var/themes_repository.
That way you may lose your changes if you modify the .css and .tpl files of an add-on in the design/themes directory and then uninstall that add-on in the Administration panel.
However, if you enable Development Mode, the files of the add-on in the design/themes directory won’t be deleted when you uninstall the add-on.
Display Smarty and PHP Errors on Screen
Sometimes you also need to redefine PHP and/or web server settings for the error messages to appear. That’s why we added the following code to local_conf.php:
Disable PHP Block Caching
CS-Cart caches blocks to reduce page loading times. However, when you work on a project, you want to see the latest changes you’ve made. That’s why you may want to disable PHP block caching by adding the following code to local_conf.php:
Database and Host Settings
You can redefine the database credentials and the HTTP host of your store. It is useful when you work on a local copy of an existing store and don’t want to change config.local.php.
Uncomment and specify these settings in local_conf.php:
Cache and Session Backend
You can use local_conf.php to redefine storage the cache backend. Uncomment the following code and specify the desired settings:
You can also change the storage backend for sessions. Uncomment the following code and specify the desired settings: