Support the ongoing development of Laravel.io →
Configuration Requests Architecture
Last updated 2 years ago.
0

In Laravel 5 you should use Config in a ServiceProvider or a Middleware. You can see both examples in the following SO question:

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

Do never touch index.php, it is immaculate.

0

Thanks but I am using Laravel in a Windows IIS environment and Windows Authentication. Since everything goes through index.php when you hit the site, that is where the 401 challenge takes place. In Laravel 4 I can use Config::set() from index.php to capture the user's login ID so I can use it throughout the application.

If I debug and put a breakpoint on Config::set() I can see it being set. However when I put a breakpoint on Config::get() in one of my controllers the key is not in the array. So even though it gets set...it is wiped out.

Last updated 9 years ago.
0

Try in the routes.php file.

0

Yes that works but doesn't solve my issue. The 401 challenge is on the index.php file, it can't be on the routes file because that is not the document root. This means that once the 401 challenge is complete on the index.php file the $_SERVER credentials are tossed.

0

Ok, you can try a terminable middleware, it will inject data into the response, instead of the request.

http://laravel.com/docs/5.0/middleware#terminable-middleware

Have you tried using Session::put() and Session::get()? Or even plain $_SESSION in index.php?

0

guys what that's mean

<tiitle>{{ config('app.name', 'my application') }}</title>

0

it means get app.name from config if defined else use 'my application' as the default value

meduprise said:

guys what that's mean

<tiitle>{{ config('app.name', 'my application') }}</title>

Last updated 8 years ago.
0

Sign in to participate in this thread!

Eventy

Your banner here too?

mikerh mikerh Joined 19 Nov 2014

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.

© 2024 Laravel.io - All rights reserved.