Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

browner12's avatar

Problem Deploying App on Forge with Bugsnag

i'm running into kind of a chicken / egg problem deploying an app I have onto a new PHP7 server I just built. The application uses Bugsnag for exception reporting. When I deploy this as a fresh install on Forge, I am getting the following error message back.

PHP Fatal error:  Uncaught Exception: Bugsnag Error: Invalid API key

If I deploy the exact same code on the existing app (where Bugsnag was added after the initial deploy) I have no issues.

So the problem seems to be the fact that my .env file doesn't exist right away, and it can't grab my API key. The problem is, I can't figure out where this exception is being generated. I thought maybe the service provider, but I can't figure it out.

Looking through the stack trace, I don't see anything other than Bugsnag stuff. It seems to me like there should be a fallback if Bugsnag fails, rather than it throwing it's own exception.

Any suggestions are greatly appreciated.

0 likes
4 replies
browner12's avatar

not a good solution. basically on an initial install I just need to disable Bugsnag, and then re-enable the code after the first installation. really hacky but it gets the job done for now.

2 likes
etNosSnake's avatar

I had this problem also. Forgot to publish the config file.

php artisan vendor:publish --provider="Bugsnag\BugsnagLaravel\BugsnagLaravelServiceProvider"
2 likes
squibby's avatar

php artisan config:cache

This will clear the cached config files and look to .env when building them back up again. I always run that whenever I change any .env variables and it fixes those issues.

Please or to participate in this conversation.