Support the ongoing development of Laravel.io →
Configuration Architecture
Last updated 1 year ago.
0

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 1 year ago.
0

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

Last updated 1 year ago.
0
Solution

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.

http://laravel.com/docs/ioc#basic-usage

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 1 year ago.
0

@Stolz

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

Last updated 1 year ago.
0

Sign in to participate in this thread!

LaraJobs

Your banner here too?

Moderators

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

Your logo here?

Laravel.io

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

© 2023 Laravel.io - All rights reserved.