Created
April 5, 2016 12:20
-
-
Save mirzabusatlic/f096c86f08b8d4b0bcd734921b65be4d to your computer and use it in GitHub Desktop.
Prevent a Laravel Artisan command from executing on a production server
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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