-
-
Notifications
You must be signed in to change notification settings - Fork 94
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
✨ Implement the key:generate command 🧑💻 Improve the Laravel router implementation 🎨 Polish the Bootloader class ➕ Add `illuminate/queue` to the project ➕ Add `illuminate/encryption` to the project
- Loading branch information
Showing
4 changed files
with
96 additions
and
28 deletions.
There are no files selected for viewing
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
<?php | ||
|
||
namespace Roots\Acorn\Console\Commands; | ||
|
||
use Illuminate\Foundation\Console\KeyGenerateCommand as FoundationKeyGenerateCommand; | ||
use Illuminate\Support\Facades\File; | ||
|
||
class KeyGenerateCommand extends FoundationKeyGenerateCommand | ||
{ | ||
/** | ||
* Write a new environment file with the given key. | ||
* | ||
* @param string $key | ||
* @return bool | ||
*/ | ||
protected function writeNewEnvironmentFileWith($key) | ||
{ | ||
$envFile = file_exists($this->laravel->environmentFilePath()) | ||
? $this->laravel->environmentFilePath() | ||
: File::closest($this->laravel->basePath(), '.env'); | ||
|
||
if (! $envFile) { | ||
$this->error('Unable to set application key. Create a .env file.'); | ||
|
||
return false; | ||
} | ||
|
||
$replaced = preg_replace( | ||
$this->keyReplacementPattern(), | ||
'APP_KEY='.$key, | ||
$input = file_get_contents($envFile) | ||
); | ||
|
||
if ($replaced === $input || $replaced === null) { | ||
$this->error('Unable to set application key. No APP_KEY variable was found in the .env file.'); | ||
|
||
return false; | ||
} | ||
|
||
file_put_contents($envFile, $replaced); | ||
|
||
return true; | ||
} | ||
} |
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