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

arkid's avatar
Level 1

php artisan just returns the command line instantly if I run my site in production mode

I have a site on a live server that worked fine and then a few months due to some change that I am unaware of php artisan stopped working. Any command at all from simply "php artisan" to something more advanced does the same thing; in all cases the cursor just returns a new line almost instantly.

I've just discovered something that makes this maybe a bit easier to troubleshoot and that is why I'm creating this post.

I discovered today that if I set the APP_ENV variable in the .env file to "local" that it suddenly it will work again. This has gotten me around my biggest problem as this means that I can actually use the command to undertake some important work I needed to.

However it's still really annoying that it isn't working when the site is in the correct APP_ENV=production mode and each time I want to run a cache clear I first have to update the .env and set it to local.

I've tried composer install / update commands but this doesn't help.

Does anyone have any ideas to assist troubleshooting this ?

0 likes
3 replies
jlrdw's avatar

I discovered today that if I set the APP_ENV variable in the .env file to "local"

But how does that work when you need to run php artisan clear:config after making the change. It would be locked into production I would think.

But now after reading this I plan on investigating deeper.

Does anyone have any ideas to assist troubleshooting this ?

Well I am going to re-read information on configuration in the documentation for starters.

Edit:

See this as well https://www.reddit.com/r/laravel/comments/cz332n/artisan_wont_run_in_production/

arkid's avatar
arkid
OP
Best Answer
Level 1

Like someone else, it was my own making this error. I had some logic deeply hidden checking

if (app()->environment('production')){ }

and it had an exit; clause if this was met. So in case anyone else gets it, do triple check your own code as it seems likely that somewhere you're probably shooting yourself in the foot ;)

1 like
lemmon's avatar

Good research, I saw that on a stack overflow.

Please or to participate in this conversation.