Support the ongoing development of Laravel.io →
Session Architecture

Hey, Just started Laravel today and I was checking some tips and tricks on how to make a multilanguage site. But the guide don't seem to be correct for Laravel 5.0. What I wanted to do can be seen on this page link to forum post Searched the entire project with Sublime but the filters.php seems to be gone.

Were shall i put the before statements in L5? Thanks for any help.

App::before(function($request) { if (Session::has('lang')) { App::setLocale(Session::get('lang')); } else { Session::put('lang', Config::get('app.locale')); } });

Last updated 2 years ago.
0

It depends where in the request cycle you want this to be set and where you want this data to be accessed. Most of the times putting it in the boot method of the AppServiceProvider will do, but sometimes it should better be placed in a route middleware (for example if you want to be able to group routes for multilanguage setup).

Last updated 10 years ago.
0

The following SO question has two answers, one with an example using a ServiceProvider and another using a Middleware.

http://stackoverflow.com/questions/28356193/laravel-5-share-variables-in-service-providers

0

Thanks, reading up on it.

0

Sign in to participate in this thread!

Eventy

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.

© 2025 Laravel.io - All rights reserved.