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

nerijunior's avatar

php artisan --env doesn't work on Homestead

On homestead with/without APP_ENV defined (in homestead.yaml) the --env on php artisan doesn't work.

I've searched some problems related but no solution.

I've two database one for dev other for testing when I set --env testing the configuration doesn't change.

0 likes
4 replies
bobbybouwmann's avatar
Level 88

I always do it like this

php artisan migrate --database=testing

Then you need to update your connections array in the config/database.php file with this

'testing' => [
    'driver'   => 'sqlite',
    'database' => storage_path().'/testing.sqlite',
    'prefix'   => '',
],

Of course you can replace this with mysql as well, just copy over the mysql stuff and place your test stuff in there ;)

1 like

Please or to participate in this conversation.