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

Making config variable global as CI3 #1297

Closed
TatwiraT opened this issue Oct 5, 2018 · 4 comments
Closed

Making config variable global as CI3 #1297

TatwiraT opened this issue Oct 5, 2018 · 4 comments

Comments

@TatwiraT
Copy link

TatwiraT commented Oct 5, 2018

I'm building a great app on the testing version of the CI4, It's realy amazing thing to see CI based on the Advanced OOP algorithms. I liked the old style although it was a bit needing tweaking on each update or new version.
some of the great features of CI3 is the globalization of variables with $config->set_item()/config_item()
it's possible with some tweaks or directly via namespaces, but it would be great if it's implemented somehow as a feature to reduce calls of classes/namespaces using custom helpers
thanks

@rmcdahal
Copy link

rmcdahal commented Oct 5, 2018

Code:
$app = config('App');
$app->brian = 'whatever you want';
Or, if you want to access it everywhere, give it object scope,
Code:
$this->app = config('App');
$this->app->brian = 'whatever you want';

You can access anything from application/Config/App (or whichever config file you are interested in), and you can even create config items on the fly. The pre-existing ones are supposed to be static, so instance-agnostic. If you wanted the same for yours, then add it to App similarly.
https://forum.codeigniter.com/thread-71819.html

@Iamscalla
Copy link
Contributor

Looking at this, Its possible if you make the property public

@lonnieezell
Copy link
Member

All of the config values are public and, as @rmcdahal pointed out, it's pretty simple to do that. Closing.

@TatwiraT
Copy link
Author

it's the pretty exact thing i needed ^^
thanks

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

4 participants