Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
Config class question
  • I am trying to get values of 'roles' from my simpleauth.php config file which is located in app/config/ The fuel docs provide this as an example
    // This will get which db connection is set to 'active' in the db config
    $active_db = Config::get('db.active');
    
    my code looks like this but i am getting nothing retruned
    $roles = Config::get('simpleauth.roles');
    print_r($roles)
    

    I am not sure what I am doing wrong but any and all help is greatly appreciated?
  • Did you load it first?
    \Config::load('simpleauth', true);
    
    This happens automatically when you load the simpleauth driver. If you do it manually, make sure the auth package is loaded.
  • I did, I tried this but it still returns nothing
    Config::load('simpleauth');
      $var = Config::get('simpleauth.roles');
      echo "<pre>";
      print_r($var);
      echo "</pre>"; 
    

    But I can get the values by doing this and just pulling the roles out of the array but that is what i though Config::get was for.
    $var = Config::load('simpleauth');
    

  • There's a difference between
    \Config::load('simpleauth');
    
    and
    \Config::load('simpleauth', true);
    

    The first one merges the config with the already loaded config, the second one creates a 'root' entry in the config array called 'simpleauth', and load the config into there. In the first case, you get the roles by using
    $roles = \Config::get('roles');
    
    in the second case with
    $roles = \Config::get('simpleauth.roles');
    

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

In this Discussion