Skip to content

Instantly share code, notes, and snippets.

@mirzabusatlic
Created April 5, 2016 12:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mirzabusatlic/f096c86f08b8d4b0bcd734921b65be4d to your computer and use it in GitHub Desktop.
Save mirzabusatlic/f096c86f08b8d4b0bcd734921b65be4d to your computer and use it in GitHub Desktop.
Prevent a Laravel Artisan command from executing on a production server
<?php
namespace App\Console;
trait PreventOnProduction
{
/**
* Prevent the command from executing on production.
*
* @param string $message
*/
protected function preventOnProduction($message = 'This command should not run in production.')
{
if ($this->laravel->environment() === 'production') {
$this->error($message);
exit;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment