Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
Edit values in config file
  • i have this array in the config file:
    'organization' =>array(
    'name' => 'example name',
    'address' => 'example street,
    'country' => 'Lebanon',
    'city' => 'Saida',
    'countryID' => '120',
    'legal_entity' => 'S.A.L',
    'default_pricing' => '(Default)',
    'default_pricing_ID' => '1',
    'default_warehouse_id' => 1,
    'email' => 'info@example.com',
    'website' => 'www.example.com',
    'phone' => '03 254526',
    'logo' => 'assets/img/Settings/LOGO.png',
    ),

    and i am trying to edit it from my website using this funciton, but it is not changing anything and not giving me an error:

    \Config::load('organization', 'foo');
                            
                                \Config::set('foo.name',\Input::param('name',''));
                                    
                                \Config::set('foo.address',\Input::param('address',''));
                                    
                                \Config::set('foo.city',\Input::param('city',''));
                                    
                                \Config::set('foo.country',\Input::param('country',''));
                                    
                                \Config::set('foo.email',\Input::param('email',''));
                                    
                                \Config::set('foo.phone',\Input::param('phone',''));
                                    
                                \Config::set('foo.website',\Input::param('website',''));
                            
                            
                            \Config::save('organization', 'foo');


    please help me if you can, thank you!!
  • What is that file called?

    Assuming, based on your load statement that file is called "organisation.php". So if you load that, you'll end up with:

    'organisation' => array(      // name of the config file
        'organisation' => array(  // name of your array
            ...
        ),
    )

    So you need to use \Config::set('foo.organisation.name', ....);

    Second point is that when you save, config files are written to the environment folder, so to ./config/development or ./config/production, and not to ./config. Files in ./config should only contain defaults for all environments.

    When you load it, both config files will be read and merged.

Howdy, Stranger!

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

In this Discussion