Skip to content

Instantly share code, notes, and snippets.

@Braunson
Created October 9, 2024 15:03
Show Gist options
  • Save Braunson/5f78fb01abfc950d9f529a4f93b612f2 to your computer and use it in GitHub Desktop.
Save Braunson/5f78fb01abfc950d9f529a4f93b612f2 to your computer and use it in GitHub Desktop.
Copy .env.example to .env and generate an APP_KEY when not set on the Composer post-install-cmd hook
{
"scripts": {
"post-install-cmd": [
"@php -r \"file_exists('.env') || copy('.env.example', '.env');\"",
"@php -r \"if (strlen(trim(file_get_contents('.env'))) > 0 && !preg_match('/^APP_KEY=.+/m', file_get_contents('.env'))) { echo shell_exec('php artisan key:generate --ansi'); }\"",
"@php -r \"file_exists('database/database.sqlite') || touch('database/database.sqlite');\""
]
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment