Framework: env() helper function does not work well in web.php

Created on 2 Oct 2016  路  5Comments  路  Source: laravel/framework

  • Laravel Version: 5.3
  • PHP Version: 7

    Description:

The env() helper function not work in /routes/web.php, when I call this function, it return me a value of null for any parameter that I pass him. In this case env( APP_URL )

Steps To Reproduce:

my file .env

APP_URL=http://test.dev

/routes/web.php

dd( env( 'APP_URL' ) ); // Return null

I hope you can help me, thanks and greetings :D (Y)

Most helpful comment

@Caxvalencia, config('app.url')

All 5 comments

You should only ever use the env function inside config files.

I understand, then, do I have no other alternative, for access to the value of APP_URL?

@Caxvalencia, config('app.url')

Great :D !! Thanks

Run php artisan config:clear

Was this page helpful?
0 / 5 - 0 ratings