-
-
Save permadiwibisono/0ddbca8409cbc957e0ed38cf4b4c69de to your computer and use it in GitHub Desktop.
Revisions
-
permadiwibisono revised this gist
Aug 12, 2018 . 1 changed file with 51 additions and 62 deletions.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 @@ -1,71 +1,60 @@ <?php namespace App\Console\Commands; use Illuminate\Support\Str; use Illuminate\Console\Command; use Symfony\Component\Console\Input\InputOption; class KeyGenerateCommand extends Command { /** * The console command name. * * @var string */ protected $name = 'key:generate'; /** * The console command description. * * @var string */ protected $description = "Set the application key"; /** * Execute the console command. * * @return void */ public function handle() { $key = $this->getRandomKey(); if ($this->option('show')) { return $this->line('<comment>'.$key.'</comment>'); } $path = base_path('.env'); if (file_exists($path)) { file_put_contents( $path, str_replace('APP_KEY=' . env('APP_KEY'), 'APP_KEY=' . $key, file_get_contents($path)) ); } $this->info("Application key [$key] set successfully."); } /** * Generate a random key for the application. * * @return string */ protected function getRandomKey() { return Str::random(32); } /** * Get the console command options. * * @return array */ protected function getOptions() { return array( array('show', null, InputOption::VALUE_NONE, 'Simply display the key instead of modifying files.'), ); } } -
krisanalfa revised this gist
May 31, 2016 . 1 changed file with 9 additions and 10 deletions.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 @@ -1,4 +1,6 @@ <?php namespace App\Console\Commands; use Illuminate\Support\Str; use Illuminate\Console\Command; @@ -29,22 +31,19 @@ public function fire() { $key = $this->getRandomKey(); if ($this->option('show')) { return $this->line('<comment>'.$key.'</comment>'); } $path = base_path('.env'); if (file_exists($path)) { file_put_contents( $path, str_replace(env('APP_KEY'), $key, file_get_contents($path)) ); } $this->info("Application key [$key] set successfully."); } -
krisanalfa revised this gist
May 20, 2015 . 1 changed file with 0 additions and 2 deletions.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 @@ -36,8 +36,6 @@ public function fire() $path = base_path('.env'); if (file_exists($path)) { file_put_contents($path, str_replace( -
krisanalfa created this gist
May 20, 2015 .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,74 @@ <?php namespace App\Console\Commands; use Illuminate\Support\Str; use Illuminate\Console\Command; use Symfony\Component\Console\Input\InputOption; class KeyGenerateCommand extends Command { /** * The console command name. * * @var string */ protected $name = 'key:generate'; /** * The console command description. * * @var string */ protected $description = "Set the application key"; /** * Execute the console command. * * @return void */ public function fire() { $key = $this->getRandomKey(); if ($this->option('show')) { return $this->line('<comment>'.$key.'</comment>'); } $path = base_path('.env'); dump($this->laravel['config']['app']); if (file_exists($path)) { file_put_contents($path, str_replace( $this->laravel['config']['app.key'], $key, file_get_contents($path) )); } $this->laravel['config']['app.key'] = $key; $this->info("Application key [$key] set successfully."); } /** * Generate a random key for the application. * * @return string */ protected function getRandomKey() { return Str::random(32); } /** * Get the console command options. * * @return array */ protected function getOptions() { return array( array('show', null, InputOption::VALUE_NONE, 'Simply display the key instead of modifying files.'), ); } }