Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Accessing Configuration::read in Controller in CakePHP

I have a separate config file for my CakePHP application which is loaded in the bootstrap.php. My question is, how can I access the Configuration's variables in my Controller? I.e. How can I perform the Configure::read('variable') function in Controller? Thanks!

like image 679
zdtorok Avatar asked Apr 24 '14 11:04

zdtorok


1 Answers

In my custom config file /app/Config/myconfig.php I define my config variables:

<?php

$config = array(
    'variable' => 'myValue'
);

In my Action I read can read the config file and get access of the variables:

Configure::load('myconfig', 'default');
$configValue = Configure::read('variable');
echo $configValue;  // myValue
like image 82
Simon Avatar answered Sep 19 '22 10:09

Simon