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

dinandmentink's avatar

Artisan serve running wrong env

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

  1. composer create-project --prefer-dist laravel/laravel test
  2. copy .env to .env.testing
  3. change in .env.testing APP_ENV to testing
  4. add <h1> {{ env('APP_ENV') }} </h1> to welcome.blade.php
  5. run php 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.

0 likes
1 reply

Please or to participate in this conversation.