Created
January 13, 2016 16:34
-
-
Save TimTruston/b6aa67d4e6d2a6f5adfb to your computer and use it in GitHub Desktop.
Revisions
-
TimTruston created this gist
Jan 13, 2016 .There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,73 @@ <?php use Illuminate\Console\Command; use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Input\InputArgument; class AppURL extends Command { /** * The console command name. * * @var string */ protected $name = 'app:url {url}'; protected function getArguments() { return [ ['url', InputArgument::OPTIONAL, 'required argument url'] ]; } /** * The console command description. * * @var string */ protected $description = 'Update the expected app url'; /** * Create a new command instance. * * @return void */ public function __construct() { parent::__construct(); } /** * Execute the console command. * * @return void */ public function fire() { $this->comment(''); $this->comment('====================================='); $this->comment(''); if(!$this->argument('url')){ $this->info('url: '.Config::get('app.url')); } else{ try { $path = app_path('config/'.App::environment().'/app.php'); $contents = File::get($path); $contents = preg_replace("/'url' => '(.*?)'/", "'url' => '".$this->argument('url')."'", $contents); File::put($path, $contents); $this->info('Sucessfully updated the url!'); } catch(Exception $e){ $this->info('There was a problem updating the url!'); $this->info(json_encode($e->getMessage())); die; } } } }