Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
Using config files in packages
  • I've created (or trying to) a package for Sage Pay. I'm having issues retrieving config properties. packages/sagepay/bootstrap.php:
    Autoloader::add_core_namespace('Sagepay');
    Autoloader::add_classes(array(
     'Sagepay\\Sagepay' => __DIR__.'/classes/sagepay.php',
    ));
    

    packages/sagepay/config/sagepay.php AND app/config/sagepay.php:
    return array('default_currency' => 'GBP');
    

    packages/sagepay/classes/sagepay.php:
    namespace Sagepay;
    
    class Sagepay
    
     public function __construct()
      parent::__construct();
      \Config::load('sagepay');
    
     public static function registration()
      return var_dump(\Config::get('sagepay.default_currency'));
    

    From a controller:
    echo \Sagepay::registration();
    
    Returns NULL I've tried removing the sagepay. in the get() but same result. Any ideas?
  • Bingo! It should be _init() not __construct() Is that the right way to do it?
  • return var_dump(\Config::get('default_currency'));
    
    now returns Array (), no matter what the config file is (string, array, etc).
  • Try :
    return var_dump(\Config::get('sagepay.default_currency'));
    

    not
    return var_dump(\Config::get('default_currency'));
    

Howdy, Stranger!

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

In this Discussion