Last active
June 28, 2022 06:32
-
-
Save wesamly/8534c83dccdc645a8b8470ad39e820f2 to your computer and use it in GitHub Desktop.
Lumen generate app key code
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 characters
<?php | |
// Use command line in generate.sh | |
// Generation code line by line | |
include __DIR__ . "/vendor/autoload.php"; | |
include __DIR__ . "/bootstrap/app.php"; | |
// Check https://github.com/laravel/framework/blob/8.x/src/Illuminate/Foundation/Console/KeyGenerateCommand.php | |
$key = "base64:" . base64_encode(Illuminate\Encryption\Encrypter::generateKey(config("app.cipher"))); | |
file_put_contents( | |
__DIR__ . "/.env", | |
preg_replace( | |
"/^APP_KEY\=/m", | |
"APP_KEY=" . $key, | |
file_get_contents(__DIR__ . "/.env") | |
) | |
); |
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 characters
# Only for empty APP_KEY | |
php -r 'include __DIR__."/vendor/autoload.php";include __DIR__."/bootstrap/app.php";$key="base64:".base64_encode(Illuminate\Encryption\Encrypter::generateKey(config("app.cipher")));file_put_contents(__DIR__."/.env",preg_replace("/^APP_KEY\=/m","APP_KEY=".$key,file_get_contents(__DIR__."/.env")));'; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment