Laravel – controller executed before everything else

Solution:

You can do such thing in the before filter, in routes.php (, for Laravel 4 its filters.php).

Or if you need to do it in controller then create a BaseController which should extend Controller, in Laravel 3 you should have this already, base.php. And all your controllers should extend this BaseController, in its __construct or in before filter do this for ease:

View::share('key', 'value');

And use it as $key in your views.

Note, View::share can be problematic sometimes.