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

madsynn's avatar

Add new Env to default laravel ENV

Where are the default environments set in laravel. not the ones inside app.php or .env but the ones laravel uses to determine its conditionals?

I need to add another one names qa with the same settings as local and development.

So how do i add a custom new enviroment. examples: qa, testing, content-only etc

0 likes
8 replies
tykus's avatar

the ones laravel uses to determine its conditionals

What do you mean, like isLocal and isProduction?

Snapey's avatar

You can load environment specific .env with a file like .env.testing

madsynn's avatar

@Snapey

How would environment specific .env like .env.testing tell laravel that the environment is should act the same as it being development or local and not show errors like

APP_DEBUG is set to true while APP_ENV is not local

madsynn's avatar

@tykus

I just meant the default environments

  • development
  • local
  • production

I need to add a new one something like testing

Then when the site is served it is considered the same as local or development and allows debug = true etc

Snapey's avatar

From the docs

Additional Environment Files Before loading your application's environment variables, Laravel determines if either the APP_ENV environment variable has been externally provided or if the --env CLI argument has been specified. If so, Laravel will attempt to load an .env.[APP_ENV] file if it exists. If it does not exist, the default .env file will be loaded.

madsynn's avatar

@Snapey Thnx as always you rock. but i dont think i am explaining my issue correctly. I have a pretty large CICD built and have 6 different environments.

I have some called

  • only_content
  • stage When i put those names in the .env they work great. no issues.
  • ENV=stage
  • ENV=only_content

Here is my issue. when i try to set another one as QA which i need to have debug features active on the server instance just like development or local the app loads with the error

APP_DEBUG is set to true while APP_ENV is not local

There are also other errors in my test files when they are ran. If i change the ENV to development the app loads and works the way it should.

So my question is how do i make a custom environment act like development or local act and allow my app to load and allow tests to run the way they were created to run?

Snapey's avatar

@madsynn strange? i can't find anything like that message in the code.

do you have enlightn installed?

madsynn's avatar

@Snapey

I do not but i will install it. If you want to replicate it just set your environment to anything other then develop or local and turn debug on. you will see it in the home page or root

Please or to participate in this conversation.