3

Just deployed a new app to production and seeing a strange bug:

One of the pages has a PHP error and throws an exception. Strangely, it's a Symfony branded exception page (screenshot), different from the ones I've seen in Laravel before. Env file is already set to production environment and has APP_DEBUG=false.

Does anyone know how to fix this?

I've tried the following to clear & reset cache, but it didn't help

php artisan config:cache

Not sure if it matters, but the app was deployed using http://deployer.org with Deployer's Laravel recipe

Brian
  • 31
  • 3
  • Set env to production and see if it works – Ravindra Jan 06 '21 at 20:13
  • Here is an excerpt from my .env: APP_ENV=production APP_DEBUG=false Still the same issue – Brian Jan 06 '21 at 20:15
  • All migrations done? Seems like you weren't control every case (i.e. there is variable vs. there is not variable) in controller's method which loads that view file. Can you share that code? – Tpojka Jan 06 '21 at 20:19
  • If I recall correctly, the difference between having APP_DEBUG on or off is whether or not you see the stack trace and environment variables. If you want a custom 500 error page you should check [error handling](https://laravel.com/docs/8.x/errors#http-exceptions). – apokryfos Jan 06 '21 at 20:31
  • 1
    Somehow the issue disappeared overnight. Woke up this morning and now seeing the standard '500 Server Error' page from Laravel without any additional changes to config files. Probably some sort of additional cache on my EC2 Instance.. Thank you guys! – Brian Jan 07 '21 at 07:54

1 Answers1

2

The mostly likely reason for this is that when deployer runs composer install, it does so with the --no-dev option, which prevents the required packages from being installed. If you want to include dev packages upon deployment, add the following to deploy.php:

set('composer_options', '--verbose --prefer-dist --no-progress --no-interaction --optimize-autoloader');

This is the default composer_options value with --no-dev removed.

There are also slightly more complex options that include having different tasks for different hosts, which is detailed here: PHPDeployer: set variable for local task based on host?

jgarcia
  • 41
  • 1
  • 5