Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Zend framework 2 : How do I access modules config value from a controller

In module.config.php file, I have set value for 'password_has_type'. And in controller I want to access that. Here is my module.config.php file:

'auth' => array(
    'password_hash_type' => 'sha512',
),
'di' => array(
    'instance' => array(
        'alias' => array(
            'auth' => 'Auth\Controller\AuthController',
            'auth_login_form' => 'Auth\Form\LoginForm',
        ),...

In controller, I have used

use Auth\Module

and in Action method I try to get access value by

echo Module::getOption('password_hash_type');

But I could not get any value?

So please can anybody help me to get that value ?

like image 607
Saidur Rahman Avatar asked Jan 26 '12 12:01

Saidur Rahman


1 Answers

Please see my answer at Access to module config in Zend Framework 2.

But to make it more concrete to your question, you would do this:

$config = $this->getServiceLocator()->get('Config');
$pwht = $config['auth']['password_hash_type'];

I hope this helps!

like image 200
tomo Avatar answered Nov 15 '22 11:11

tomo