CakePhp 3.x | Declaration of user defined constants

Author - Parminder Kaur
15.02.2017
|
0 Comments
|

In cakephp 3 we declare constants in bootstrap.php file under /app/config folder.

A constant can be declared as:

Configure::write(‘CONSTANT_NAME’, Value, true);

Example: Configure::write(‘USERNAME’, ‘Webners’, true);

To use this constant in another file, use this:

use Cake\Core\Configure;

Now the constant can be accessed by read function.

Configure::read(‘CONSTANT_NAME’);

Example: Configure::read(‘USERNAME’);

Webner Solutions is a Software Development company focused on developing Insurance Agency Management Systems, Learning Management Systems and Salesforce apps. Contact us at dev@webners.com for your Insurance, eLearning and Salesforce applications.

Leave a Reply

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

Send your message