How do I run Artisan in a specific environment?

1

How can I do to run Artisan as a specific environment?

Well when I squeeze

 php artisan tinker

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

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

Does anyone know how to set the environment where Artisan at runtime?

    
asked by anonymous 23.03.2016 / 22:03

1 answer

1

This can be solved quite simply. Just use --env=nome_do_ambiente to make artisan recognize another environment.

Example:

  php artisan tinker --env=local

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

To test, you can use the following example:

#app/config/app.php

 'debug' => false


#app/config/local/app.php

'debug' => true

To test the settings of the local environment, you can do this:

php artisan tinker --env=local

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

To test the production environment, simply use the production option, or pass no optional arguments (unless you have not set up the bootstrap/start.php - Read about it here ).

php artisan tinker 

> Config::get('app.debug');
false
    
13.04.2017 / 14:59