Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .env
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

###> symfony/framework-bundle ###
APP_ENV=dev
APP_SECRET=2ca64f8d83b9e89f5f19d672841d6bb8
APP_SECRET=%generate(secret)%
#TRUSTED_PROXIES=127.0.0.0/8,10.0.0.0/8,172.16.0.0/12,192.168.0.0/16
#TRUSTED_HOSTS='^(localhost|example\.com)$'
###< symfony/framework-bundle ###
Expand Down
16 changes: 16 additions & 0 deletions .env.setup.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?php

$env = file_get_contents('.env');

if (!preg_match('{^APP_SECRET=("?)%generate\(secret\)%\1([\r\n]++)}m', $env, $m)) {
return;
}

$eol = $m[2];
$local = is_file('.env.local') ? file_get_contents('.env.local') : '';

if (preg_match('{^APP_SECRET=}m', $local)) {
return;
}

file_put_contents('.env.local', 'APP_SECRET="'.bin2hex(random_bytes(16)).'"'.$eol.$local);
1 change: 1 addition & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@
},
"scripts": {
"auto-scripts": {
".env.setup.php": "php-script",
"cache:clear": "symfony-cmd",
"assets:install %PUBLIC_DIR%": "symfony-cmd",
"importmap:install": "symfony-cmd",
Expand Down
Loading