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

php artisan down --allow
laravel production mode
laravel change production mode
application in production command cancelled
laravel check is production
laravel 4.2 get environment
php artisan environment variables
laravel production to dev

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.

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', '')

Read the documentation and this answer as well.

Configuration - Laravel, Contribute to barryvdh/laravel-ide-helper development by creating an This package generates helper files that enable your IDE to provide accurate which means if you don't install dev dependencies in production, it also won't You can turn them off by setting the config write_model_relation_count_properties to false . 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.

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.

barryvdh/laravel-ide-helper, It's also really easy to organise your configuration files because you By default your Laravel application will be in the production environment. This is no longer a feature out of the box, but you could pass the For example, say I wanted to specify how often the cache should expire in my configuration. In your production environment, this value should always be false. If the value is set to true in production, you risk exposing sensitive configuration values to your application's end users. The Exception Handler. The Report Method. All exceptions are handled by the App\Exceptions\Handler class. This class contains two methods: report and

In case if anyone stumbled upon this question while searching for similar problem in a lumen installation I'd suggest to check the .env file and add APP_ENV=local if its not already there. It solved my problem.

Working with Configuration in Laravel 4, How can I disable laravel error log in production? That line 'debug' => env('​APP_DEBUG', false) says look for the value APP_DEBUG in the .env file and if you can't find it then set it false. Out of the box, .env has it set to true. Come inside, see for yourself, and massively level up your development skills in the process. I recently put a Laravel-written web application into production and I wish there was an article like this one that tells me about things I should do or use to make my life much easier.

Hopefully this will help someone else. I suddenly had an issue where my dev site I was building stopped connecting to the DB saying:

PDOException SQLSTATE[HY000] [1049] Unknown database 'forge' failed

I was also receiving errors such as the OP when trying to run artisan migrate:refresh etc, the error was stating that i was in production etc etc.

After much head scratching (!) I found that my hostname value set inside the /bootstrap/start.php was wrong, because my hostname had changed on my macbook pro!? I have no idea how but it changed from something like RobMacbookPro2.local to RobMacbookPro.local. This meant it fell back to production thus loading the incorrect database.php file with the standard DB=forge (which was wrong)

Check this guide:

Pay particular attention to the code:


$env = $app->detectEnvironment(array(

    'local' => array('your-machine-name'),


On a mac and probably linux? you can determine your hostname by typing # hostname in terminal.

Hope that saves someone some time!

How to disable Laravel debugger, Once logged in, you'll copy your username and password over to the Laravel .​env file as Our application can send mail, but it's not using queues. Of course you won't want to SSH into your production server and run php artisan of retries or of time, it can now be taken out of the queue and put into the failed_jobs table. In Laravel 4.2, I'm using App::detectEnvironment to change database according to machine name. I also now need to have it change environment according to an environment variable. I've tried to combine but it doesn't work at the moment and I'm not sure how to combine the two techniques.

The basics of Laravel Queues using Redis and Horizon, Chapter 2, Composer All Over, will enable you to install and use the In development it is fine to use a dev-master branch, but in production, it is Before you go off and start writing your first Laravel application, here are it says on the tin. When you're ready to deploy your Laravel application to production, there are some important things you can do to make sure your application is running as efficiently as possible. In this document, we'll cover some great starting points for making sure your Laravel application is deployed properly. Server Configuration. Nginx

[PDF] Getting Started with Laravel 4, With your application code in place, you can move on to defining your services with Docker Compose. Step 2 — Creating the Docker Compose File. Building your  However once you get to the stage where you want to push your application to a staging or production server, you will need to set up your environments so your application has the correct configuration settings for that environment. The environment of your Laravel application is handled in boostrap/start.php. In this file you will see the

How To Set Up Laravel, Nginx, and MySQL with Docker Compose , Queues are a great way to take some task out of the user-flow and put them in the (most of) how I set up Beanstalkd to work with Laravel 4 in a production environment. tasks; They make great candidates for work which we can off-​load to a queue. cd /path/to/laravel/application $ composer require pda/​pheanstalk ~2.0  For example, you may wish to use a different cache driver locally than you do on your production server. To make this a cinch, Laravel utilizes the DotEnv PHP library by Vance Lucas. In a fresh Laravel installation, the root directory of your application will contain a .env.example file.

  • For vagrant users - host name is not your pc but virtual machine, like: vagrant-ubuntu-trusty-64. I found it running echo gethostname(); die;
  • Alright, that fixed it. Thanks. I should mention though that I changed 'local' to 'development' (which are the same thing in my case) because I was getting an 'access denied 'homestead'@'localhost'' error, which is strange since my user is root, not homestead.
  • @surfer190, bootstrap/start.php, read more here.
  • For Lumen enable Dotenv::load(__DIR__.'/../'); in bootstrap\app.php
  • This is a problem I'm facing through Travis CI. I don't have permission nor the ability to change the machine name. What would I do in this scenario?
  • @Arcrammer Curious, I wonder why that is. At any rate, give this code a try: $app->detectEnvironment(); $env = getenv('ENV') ?: 'production'; then use this command line: ENV=local php artisan migrate:refresh. The basic point being that L4.2 requires you call detectEnvironment, but after that you can set $env to whatever you like.
  • I don't have this problem. I was just passing by! haha Thanks, though.
  • Update: Artisan has an --env flag which allows you to set your preferred environment. I can confirm once again that piping yes cancels the command, although there's also an -n flag (which stands for 'no interaction') and using that prevents Artisan from asking for confirmation. Also, I'm using Laravel 5+ for this particular application.
  • Another Update: I take it back! I could have sworn that worked but it doesn't work now. However, you can pass --force which will run the migrations without asking for confirmation. See: