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'
]
]];
<?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;
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