PHP | core.php and some important settings

|
| By Webner

In CakePHP application, core.php is configuration file and is located at app/Config/core.php. This file contains various variable definitions and constant definitions that alter the behavior of the application. The description of some important variables and their effect on the application is given below:

Debug: It changes debugging output of CakePHP. Following are the valid values of this variable:

0 = Production mode (No output).
1 = It shows errors and warnings.
2 = It shows errors, warnings and all database related errors.

For Example: Once we had accidentally deleted the tmp folder from our application which is used to write logs and cache. To fix this we copied the tmp folder from our backup and pasted it in our application. But even after that when we were trying to access any url of our site in the browser, we were getting blank page (with no error or warning). Then we used the debugger feature of cakephp and changed value of debug variable to 2 as below:

Configure::write('debug', 2);

And came to know what was the actual reason. And the reason was that the new folder which we copied did not have the permissions to write cache as shown in the screenshot below:

32
App.encoding: This is used to define the default encoding method for your application. This encoding is used to encode the entities and to generate the charset in the layout. By default “UTF-8” method is used as shown below:

Configure::write('App.encoding', 'UTF-8');

But you can changes it to any other encoding method but make sure it should match the encoding values specified for your database.

Config.timezone: Config.timezone property is available in which you can set your own timezone string. If a method of CakeTime class is called with $timezone parameter as null and Config.timezone is set, then the value of `Config.timezone` will be used. This feature allows you to set timezone of your choice just once instead of passing it each time in function calls. But you can also change it dynamically in your AppController to be available all over the website. See the example given below:

$timezone = “your timezone string”;
Configure::write('Config.timezone', $timezone);
Now if you want to access and display it on any page of your website then just extract its value as follows :
$currTimezone =  Configure::read('Config.timezone');
Also Uncomment this line and correct your server timezone to fix any date & time related errors :
//date_default_timezone_set('UTC');

Leave a Reply

Your email address will not be published. Required fields are marked *