Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to get all items of a package config #41

Closed
billmn opened this issue Jan 14, 2013 · 12 comments
Closed

Unable to get all items of a package config #41

billmn opened this issue Jan 14, 2013 · 12 comments

Comments

@billmn
Copy link
Contributor

billmn commented Jan 14, 2013

I've created a package with it's own config file ... I can retrieve an item of this configuration with :

Config::get('package::config_key')

but I cannot retrieve all items of this package using :

Config::get('package')

After this I think that can be useful add this tip to the docs

@bencorlett
Copy link
Contributor

Hi @billmn

This is true, maybe you should put a pull request onto http://www.github.com/laravel/docs :)

Good point though as this can throw people off initially.

@jasonlewis
Copy link
Contributor

You still have to provide the filename, even if that file is the config.php file. This should work: Config::get('package::config') or if you have a different file, Config::get('package::filename')

Remember you can have multiple config files so Laravel doesn't know which file to fetch the keys out of. Unless you want to load all config items from all files with Config::get('package')?

@billmn
Copy link
Contributor Author

billmn commented Jan 15, 2013

No ... it doesn't work, I've tried :

Config::package('billmn/twig', 'twig');
var_dump(Config::get('twig::config'));

with this I can get options for the specified key ('view_extensions') :

Config::package('billmn/twig', 'twig');
var_dump(Config::get('twig::view_extensions'));

Remember you can have multiple config files so Laravel doesn't know which file to fetch the keys out of. Unless you want to load all config items from all files with Config::get('package')?

I would need to get all options for a specified config file ... I don't need to have them all

@jasonlewis
Copy link
Contributor

You're setting up the config wrong for the package. The second parameter should be the path to the config directory, the third parameter is an optional namespace if you prefer to specify one.

Config::package('billmn/twig', __DIR__.'/../../config', 'twig');

Laravel will automatically use twig though so in this case you don't really need to provide the 3rd parameter.

@bencorlett
Copy link
Contributor

Oh Jason that's not right as of the last 3 days. It's now reversed cheek out the ServiceProvider

Sent from my iPhone
Please excuse my brevity

On 15/01/2013, at 9:25 PM, Jason Lewis notifications@github.com wrote:

You're setting up the config wrong for the package. The second parameter should be the path to the config directory, the third parameter is an optional namespace if you prefer to specify one.

Config::package('billmn/twig', DIR.'/../../config', 'twig');
Laravel will automatically use twig though so in this case you don't really need to provide the 3rd parameter.


Reply to this email directly or view it on GitHub.

@jasonlewis
Copy link
Contributor

@bencorlett I'm talking about config registration separately, not the package registration as per the service provider. See here: https://github.com/laravel/framework/blob/master/src/Illuminate/Config/Repository.php#L218

@bencorlett
Copy link
Contributor

Oh, sorry my bad misread there

Sent from my iPhone
Please excuse my brevity

On 15/01/2013, at 9:33 PM, Jason Lewis notifications@github.com wrote:

@bencorlett I'm talking about config registration separately, not the package registration as per the service provider. See here: https://github.com/laravel/framework/blob/master/src/Illuminate/Config/Repository.php#L218


Reply to this email directly or view it on GitHub.

@billmn
Copy link
Contributor Author

billmn commented Jan 15, 2013

@jasonlewis Right ... now it works fine.

Thanks for the support

@billmn billmn closed this as completed Jan 15, 2013
@billmn
Copy link
Contributor Author

billmn commented Jan 15, 2013

@jasonlewis What about add this on the docs? is missing now

@jasonlewis
Copy link
Contributor

@billmn No worries at all.

Which part needs clarifying in the docs? Actually getting all keys from an entire file?

@billmn
Copy link
Contributor Author

billmn commented Jan 15, 2013

Exactly ... in particular in this section :
http://four.laravel.com/docs/packages#package-configuration

unfortunately my english sucks :)

@jasonlewis
Copy link
Contributor

No worries at all. I've noted it down and will clarify it when I get the chance. Thanks for the feedback @billmn. :)

joelharkes pushed a commit to joelharkes/framework_old that referenced this issue Mar 7, 2019
…des-and-messages

Handle API error codes & messages
gonzalom pushed a commit to Hydrane/tmp-laravel-framework that referenced this issue Oct 12, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants