dlook's avatar
Level 4

Laravel not "accepting" changes to both .env and app.php files

I am having a bit weird problem - been working on a Laravel 5.2 project for some time now and today I wanted to change environment and debug to production and false (it has been set to local and true), so these are my files

.env:

APP_ENV=production
APP_DEBUG=false

app.php

 'env' => env('APP_ENV', 'production'),
 'debug' => env('APP_DEBUG', false),

But when I run:

 php artisan env

it returns:

Current application environment: local

When I dump:

dd(App::environment()) 

it returns:

"local"

Also when I dump:

 var_dump(getenv('APP_ENV')); returns:

it returns:

bool(false)

And also even tho the debug is set to false it is still showing full debug "error page".

0 likes
17 replies
dlook's avatar
Level 4

@SaeedPrez Hi, I just have run that command and now I'm getting blank pages for all my routes...

Edit it's showing 500 error... "is currently unable to handle this request."

SaeedPrez's avatar

@dlook check your laravel log files for more detail, it sounds like you have some issues in your config files.

dlook's avatar
Level 4

Okay @SaeedPrez , I reinstalled ubuntu and it's working now - but I updated to L5.3 and now my Blade files are not "pulling" classes like for example

{!! Form::open(array('route' => 'wizard', 'class' => 'sale', 'method' => 'POST', 'files' => true)) !!}

Is returning now

Class 'Form' not found (View: ...)

What am I missing here?

SaeedPrez's avatar

Try

composer dump-autoload
php artisan optimize
clay's avatar

do you have the LaravelCollective HTML/Form package in your composer.json? Laravel Collective

in order to use Form::open() you need this package.

dlook's avatar
Level 4

@SaeedPrez I tried all of that, and cache clearing and everything else....

@clay yes sir I do have it. I have it in use for some time now but after I moved from 5.2 to 5.3 (yes I've updated the laravelcollective as well) it just isn't pulling in the class. Same thing happened with Entrust class (Zizaco roles) but I bypassed it from Entrust::hasRole to Auth::user()->hasRole ... It seems only classes that are "native" to Laravel are working in Blade views, other returingin "Class not found".

clay's avatar

hmm only other idea i have may be to try php artisan clear-compiled

dlook's avatar
Level 4

Yeah, tried that as well @clay ... It's just weird... Everything else works, for example Session facade is working perfectly inside the {!! !!}, but Form returns "Class 'Form' not found", and it is de facto there, installed via composer, added to app config both as alias and facade. As I've said same thing is happening with other dependency, Zizaco Roles package - it returns "Class 'Entrust' not found" - and that simply is not true it is installed, and added to app config...

andy's avatar

Have you declared "Form" in app.php?

clay's avatar
clay
Best Answer
Level 20

if it were me, I'd probably backup then delete my vendor folder and composer install just to make sure nothing was broke in my autoloading.

PeterPan's avatar

Did you declare your LaravelCollective HTML/Form package

Finally, add two class aliases to the aliases array of config/app.php:

  'aliases' => [
    // ...
      'Form' => Collective\Html\FormFacade::class,
      'Html' => Collective\Html\HtmlFacade::class,
    // ...
  ],
dlook's avatar
Level 4

@andy and @PeterPan, guys I already said I did in my previous comment"... installed via composer, added to app config both as alias and facade... ", but thanks anyway.

@clay, I will try that, stay tuned.

dlook's avatar
Level 4

Wow @clay you're creative yet simple reasoning solved my problem. You're the man!

2 likes
Shahrukh4's avatar

Sometimes when you changed in your .env file it does not take correct values from that, the problem is due to some configuration cache.Try running following commands, hope will work

php artisan config:cache //flush all cached env variable
php artisan config:clear   //repopulate all the env variable
php artisan cache:clear    //flush all the cached content
zemmyindrapatih's avatar

I often get this situation too. And my solution adding to @shahrukh4 is stopping web server and then starting again. Then my updated configuration read as expected.

I think web server also have its own cache.

Please or to participate in this conversation.