panthro
panthro

Reputation: 24061

Get a var from a config file?

I'm using a package (aws) and I wish to get a var from it's config file.

The config file is located in:

config>packages>aws>aws-sdk-php-laravel>config

I've tried:

Config::get('packages.aws.aws-sdk-php-laravel.config.key')

But no luck, any ideas?

Upvotes: 1

Views: 137

Answers (2)

Antonio Carlos Ribeiro
Antonio Carlos Ribeiro

Reputation: 87719

Use the package notation for config files:

Config::get('aws/aws-sdk-php-laravel::key');

And you may also have to add the namespace to Laravel:

Config::addNamespace('aws/aws-sdk-php-laravel', __DIR__.'/path/to/config');

Upvotes: 0

ollieread
ollieread

Reputation: 6248

Config is easily accessed and Laravel has support for packages. The structure for calling it would be.

Config::get('package::file.option');

I've just taken a look at the package you are using, and they've set up a nice handy namespace for access. Since the package only has one config file, you can also omit that, like so:

Config::get('aws::key');

For more information regarding third party package configuration, here's the Laravel documentation on the subject http://laravel.com/docs/packages#package-configuration.

Hope that helps.

Upvotes: 2

Related Questions