Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Laravel 4.2 says my application is in production. How do I turn this off?

I have a fresh install of Laravel. When running php artisan migrate:refresh I get a message saying Application In Production! Do you really wish to run this command?'

I know this is an update in 4.2, however I can't figure out how to turn it off.

I found in the source that it comes from Illuminate\Console\ConfirmableTrait and runs if this if test passes : if ($this->getLaravel()->environment() == 'production')

I'm not sure why it thinks I'm in production. I never setup any environments. This is the default environment detection, which I'm still currently using.

$env = $app->detectEnvironment(array(      'local' => array('homestead')  )); 

Also, if I set a production environment to a hostname that isn't my machine, I still have the same problem.

like image 753
Brennan Hoeting Avatar asked Jun 06 '14 23:06

Brennan Hoeting


People also ask

How do I turn off laravel?

How to stop laravel server? Well you have started your laravel server successfully now you want to stop server. To execute php artisan serve stop simply goto your commnad line where your server is running and press ctrl+c. It will stop your server.

What is maintenance mode in laravel?

Maintenance mode: The maintenance mode allows you to display a user-friendly notice to your users instead of a broken site during website maintenance. It also allows you to safely perform any maintenance task while making sure that people who need access to the website has the access.

How stop all artisan serve in php?

“how to stop php artisan serve” Code Answerand press ctrl+c. It will stop your server.

What does php artisan down do?

What happens after you run php artisan down is that it creates a file named down inside storage/framework . After running php artisan up the file is removed. You can create the file manually inside storage/framework . It will down your project.

How to configure Laravel to automatically detect the environment?

Just specify a machine name for the host that matches a given environment, then laravel will automatically detect the environment (default is production ), for example:

How do I install Laravel on Ubuntu?

You may also install Laravel by issuing the Composer create-project command in your terminal: Once Composer is installed, download the 4.2 version of the Laravel framework and extract its contents into a directory on your server.

What is the default Laravel env file?

Laravel's default .env file contains some common configuration values that may differ based on whether your application is running locally or on a production web server. These values are then retrieved from various Laravel configuration files within the config directory using Laravel's env function.

How do I retrieve values from Laravel config files?

These values are then retrieved from various Laravel configuration files within the config directory using Laravel's env function. If you are developing with a team, you may wish to continue including a .env.example file with your application.


2 Answers

Just specify a machine name for the host that matches a given environment, then laravel will automatically detect the environment (default is production), for example:

$env = $app->detectEnvironment(array(      //'local' => array('homestead'),      'local' => array('*.dev', gethostname()),     'production' => array('*.com', '*.net', 'www.somedomain.com') )); 

Read the documentation and this answer as well.

like image 160
The Alpha Avatar answered Oct 05 '22 23:10

The Alpha


Setting your environment to something other than production is The Right Way. See the accepted answer.

But, if you're looking for A Quick Fix you can use (in UNIXoid environments):

yes | php artisan migrate:refresh 

All this does is send a stream of "y" to the program, which acts like you pressed "y" when prompted.

I find this to be a little better than --force, as not all the artisan commands support force.

like image 24
bishop Avatar answered Oct 05 '22 23:10

bishop