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

scrappy's avatar

laravel new <project> using pre-built env

I've tried to search, and am drawing a blank ...

Is there a way of setup a .env file to be used when I run 'laravel new' ... ?

Using the latest installer / laravel, I can set '--database' to PostgreSQL, but there appears to be no way to set any of the values for the environment ( server, user, database, etc ) ... so of course, the migration step fails, since its trying to connect to a bogus database.

I tried to create a .env file with the right settings in the directory that I'm creating the new project into, but then I have to use --force, and that overwrites the .env file that is there ... so that doesn't help.

I read in the configuration docs for 11.x about using the APP_ENV or --env CLI option, but having tried the former, I suspect that only applies after the initialization is complete, as it did nothing ... and I couldn't find an --env option, although I suspect that too only applies after the fact.

Seems odd to have the migrate db step in the installer if you can't actually set the DB Connection information, so I have to be missing something.

Always happy with pointer to the docs to read if its something I missed ... ?

Thanks ...

0 likes
2 replies
jlrdw's avatar

If using other than sqlite, wait to migrate after your db is setup in .env.

Snapey's avatar

You probably have a fair complaint, but I would let it build sqlite database, setup your env and rerun migrations, which is what you would have done previously. Optionally, delete the sqlite db.

Please or to participate in this conversation.