Pages

Wednesday, June 16, 2021

cake-php : create and use a configuration file

 

This is a reminder to use variables from a configuration file with cake-php 3.8 framework.

Configuration file

First, create yuzu_config.php in config directory :

Then add your configuration like the following :

vi yuzu_config.php
<?php
return [
'organisation' => [
    'LABO' => [
        'code' => '3',
        'label' => 'label1',
        'level' => '1'
        ]
]];

In bootstrap.php, you have to load your configuration file :

Configure::load('yuzu_config', 'default');



The last step is to use it :

use Cake\Log\Log;
use Cake\Core\Configure;

$arr = Configure::read('organisation.LABO');
$code = $arr['code'];
Log::debug($code);


Version : cake-php 3.8.x





No comments:

Post a Comment

Débutez en crypto-monnaie de manière ludique avec les projets "Move to earn"

Les projets "Move to earn" sont des projets très en vogue en ce moment dans le monde de la crypto-monnaie. Le principe est simple ...