Support the ongoing development of →
Configuration Architecture
Last updated 2 years ago.

Not sure what kind of values you are setting but maybe $_GET would do the job ? You could get values like so Input::get('value').

Last updated 2 years ago.

I have an object that I want to be accessible within controllers and views.

Last updated 2 years ago.

Global variables are bad, you should refactor your code, perhaps to a class with all the ads functionality.

Knowing that, the answer to your question: the laravel way of sharing something with all the application is binding it to the IoC. It's supposed to be used for binding classes and dependency injection but can be also used to store an scalar value.

To bind a shared component:

App::singleton('foo', function($app)
	return 'foooooo';

To use it in any part of your app:

echo App::make('foo'); // will print 'foooooo'
Last updated 2 years ago.


Thanks! I finally decided to use Laravel's IoC!

Last updated 2 years ago.

Sign in to participate in this thread!


Your banner here too?


We'd like to thank these amazing companies for supporting us

Your logo here?

The Laravel portal for problem solving, knowledge sharing and community building.

© 2024 - All rights reserved.