CakePHP – Configuration

CakePHP – Configuration

CakePHP comes with one configuration file by default and we can modify it according to our needs. There is one dedicated folder “config” for this purpose. CakePHP comes withdifferent configuration options.

General Configuration

The following table describes the role of various variables and how they affect your CakePHP application.

S.NoVariable Name & Description

Changes CakePHP debugging output.

false = Production mode. No error messages, errors, or warnings shown.

true = Errors and warnings shown.


The namespace to find app classes under.


Un-comment this definition if you don’t plan to use Apache’s mod_rewrite with CakePHP. Don’t forget to remove your .htaccess files too.


The base directory the app resides in. If false, this will be auto detected.


Define what encoding your application uses. This encoding is used to generate the charset in the layout, and encode entities. It should match the encoding values specified for your database.


The webroot directory.


The file path to webroot.


The fully qualified domain name (including protocol) to your application’s root.


Web path to the public images directory under webroot.


Web path to the public css directory under webroot.


Web path to the public js directory under webroot.


Configure paths for non-class based resources. Supports the plugins, templates, locales subkeys, which allow the definition of paths for plugins, view templates and locale files respectively.


A random string used in hashing. This value is also used as the HMAC salt when doing symmetric encryption.


Appends a timestamp which is last modified time of the particular file at the end of asset files URLs (CSS, JavaScript, Image) when using proper helpers. Valid values −

  • (bool) false – Doesn’t do anything (default)
  • (bool) true – Appends the timestamp when debug is true
  • (string) ‘force’ – Always appends the timestamp

Databases Configuration

Database can be configured in config/app.php file. This file contains a default connection with provided parameters which can be modified as per our choice. The below screenshot shows the default parameters and values which should be modified as per the requirement.


Let’s understand each parameter in detail −

S.NOKey & Description

The fully namespaced class name of the class that represents the connection to a database server. This class is responsible for loading the database driver, providing SQL transaction mechanisms and preparing SQL statements among other things.


The class name of the driver used to implements all specificities for a database engine. This can either be a short classname using plugin syntax, a fully namespaced name, or a constructed driver instance. Examples of short classnames are Mysql, Sqlite, Postgres, and Sqlserver.


Whether or not to use a persistent connection to the database.


The database server’s hostname (or IP address).


Database username


Database password


Name of Database

8port (optional)

The TCP port or Unix socket used to connect to the server.


Indicates the character set to use when sending SQL statements to the server like ‘utf8’ etc.


Server timezone to set.


Used in PostgreSQL database setups to specify which schema to use.


Used by drivers that support it to connect via Unix socket files. If you are using PostgreSQL and want to use Unix sockets, leave the host key blank.


The file path to the SSL key file. (Only supported by MySQL).


The file path to the SSL certificate file. (Only supported by MySQL).


The file path to the SSL certificate authority. (Only supported by MySQL).


A list of queries that should be sent to the database server as when the connection is created.


Set to true to enable query logging. When enabled queries will be logged at a debug level with the queriesLog scope.


Set to true if you are using reserved words or special characters in your table or column names. Enabling this setting will result in queries built using the Query Builder having identifiers quoted when creating SQL. It decreases performance.


An associative array of PDO constants that should be passed to the underlying PDO instance.


Either boolean true, or a string containing the cache configuration to store meta data in. Having metadata caching disable is not advised and can result in very poor performance.

Was this article helpful?

Related Articles

Leave A Comment?

You must be logged in to post a comment.