automate environment file creation

added a post install script to the composer.json file to automate the
creation of the .env file which hold app specific configs

also added a helper function to create new keys in the future
This commit is contained in:
ro 2024-06-30 18:45:41 -06:00
parent 928d5468db
commit fb3aff6c85
No known key found for this signature in database
GPG key ID: 29B551CDBD4D3B50
3 changed files with 14 additions and 3 deletions

View file

@ -1,5 +1,7 @@
<?php
use Illuminate\Encryption\Encrypter;
function createUUID()
{
if (function_exists('com_create_guid') === true) {
@ -56,6 +58,11 @@ function randomString(int $length)
return $string;
}
function createAppKey()
{
return 'base64:' . base64_encode(Encrypter::generateKey(config('app.cipher')));
}
function delete_directory($dirPath)
{
if (is_dir($dirPath)) {

View file

@ -67,6 +67,10 @@
],
"start": [
"@php -S localhost:8000 -t public/"
],
"post-install-cmd": [
"php -r \"copy('.env.example', '.env');\"",
"php artisan key:generate"
]
},
"extra": {

View file

@ -16,7 +16,7 @@ define('LARAVEL_START', microtime(true));
|
*/
if (file_exists($maintenance = __DIR__.'/../storage/framework/maintenance.php')) {
if (file_exists($maintenance = __DIR__ . '/../storage/framework/maintenance.php')) {
require $maintenance;
}
@ -31,7 +31,7 @@ if (file_exists($maintenance = __DIR__.'/../storage/framework/maintenance.php'))
|
*/
require __DIR__.'/../vendor/autoload.php';
require __DIR__ . '/../vendor/autoload.php';
/*
|--------------------------------------------------------------------------
@ -44,7 +44,7 @@ require __DIR__.'/../vendor/autoload.php';
|
*/
$app = require_once __DIR__.'/../bootstrap/app.php';
$app = require_once __DIR__ . '/../bootstrap/app.php';
$kernel = $app->make(Kernel::class);