Level 51
You can try setting the environment on the command line
APP_ENV=testing php artisan serve
https://laravel.io/forum/02-03-2014-testing-artisan-server-environment-setting
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
I am running into a problem with artisan serve yielding the wrong env variables. Steps to reproduce based solely on laravel/laravel:
Laravel 5.8.3 php 7.2.15 ubuntu 18.10
composer create-project --prefer-dist laravel/laravel test
.env to .env.testing
.env.testing APP_ENV to testing
<h1> {{ env('APP_ENV') }} </h1> to welcome.blade.phpphp artisan serve --env=testing
I would expect the page to now show testing. Instead it will show local. From within tinker however the correct testing will be shown for env('APP_ENV').
Anyone else able to reproduce this and/or have a solution / workaround? I have already tried to config:clear.
Please or to participate in this conversation.