How do I run Artisan in a specific environment?

Asked

Viewed 513 times

1

How can I perform the Artisan as a specific environment?

'Cause when I spin

 php artisan tinker

It is generating an error because it is recognizing the configuration of the production database. But I need to run it in the environment "local", because I have different bank settings in this environment.

I don’t want to have to change my file bootstrap/start.php and check if it is running through the console $app->runningInConsole(), because, when I update my data on the server, I want the artisan ride in production environment.

Does anyone know how to define the environment in which the Artisan at runtime?

1 answer

1


This can be solved very simply. Just use the option --env=nome_do_ambiente to make the artisan recognise another environment.

Example:

  php artisan tinker --env=local

This makes the artisan capture all the settings you set in the folder config/local.

To test, you can use the following example:

#app/config/app.php

 'debug' => false


#app/config/local/app.php

'debug' => true

To test your environment settings local, you can do this:

php artisan tinker --env=local

> Config::get('app.debug');
true

To test the production environment, just use the option production, or pass no optional argument (unless you have not configured the file bootstrap/start.php - Read about it here).

php artisan tinker 

> Config::get('app.debug');
false

Browser other questions tagged

You are not signed in. Login or sign up in order to post.