heroku / php-getting-started

Getting Started with PHP on Heroku.
https://devcenter.heroku.com/articles/getting-started-with-php
194 stars 782 forks source link

Is currently unable to handle request [HTTP ERROR 500] #43

Closed heardofdezz closed 3 years ago

heardofdezz commented 3 years ago

For the past week i have trying to deploy on heroku and get an handle on the system and how it works, build after build debugs after debugs, now i have reached an error that kind of baffles and i dont know which direction to take, i have setup a symfony/Bootstrap aoo deployed on Heroku, the build goes well, now that im trying to accept the app url i get a.

'This page isn’t working interfaceapp.herokuapp.com is currently unable to handle this request. HTTP ERROR 500 ', nothing shows up on the deploy log i have to way to understand why am i getting this error.

heardofdezz commented 3 years ago

After much of poking around and trying to find a solution i stumble on a rather interesting heroku cli command heroku -logs -a app_name.

i had this output :

[13-Nov-2020 10:11:15 UTC] PHP Fatal error: Uncaught Symfony\Component\Dotenv\Exception\PathException: Unable to read the "/app/.env" environment file. in /app/vendor/symfony/dotenv/Dotenv.php:565 2020-11-13T10:11:15.142981+00:00 app[web.1]: Stack trace: 2020-11-13T10:11:15.143161+00:00 app[web.1]: #0 /app/vendor/symfony/dotenv/Dotenv.php(92): Symfony\Component\Dotenv\Dotenv->doLoad() 2020-11-13T10:11:15.143350+00:00 app[web.1]: #1 /app/vendor/symfony/dotenv/Dotenv.php(114): Symfony\Component\Dotenv\Dotenv->load() 2020-11-13T10:11:15.143543+00:00 app[web.1]: #2 /app/vendor/symfony/dotenv/Dotenv.php(157): Symfony\Component\Dotenv\Dotenv->loadEnv() 2020-11-13T10:11:15.143701+00:00 app[web.1]: #3 /app/public/index.php(10): Symfony\Component\Dotenv\Dotenv->bootEnv() 2020-11-13T10:11:15.143724+00:00 app[web.1]: #4 {main}

Which meant that my app couldnt read my .env file, since it is the first time im deploying a project that has a stage an prod branch, i removed the .env from both repositories (need to point out that Heroku is connected to my github repository).

My .env file from other branch contained dev env variables for the database and app_env. So what i did is i went to my heroku app dashboard, clicked on on my staging app then went to the samething and created a APP_ENV var with a value of staging. i added the postgresql add on which automaticaly created a DATABASE_URL var with a generated value attached to it.

Now for all of this to work i had to create a .env file for my staging branch on my github repo, a copy paste of the standard .env did the job, for this to be able i obviously had to remove the value attached to the APP_ENV and DATABASE_URL variables then commit and pushed it. Ran another build on Heroku now my app index page is finally showing and the error is gone :).