#!/usr/bin/env php
<?php
$file=dirname(__DIR__).'/.env.platform';
if (file_exists($file)) {fwrite(STDERR,".env.platform existe déjà. Ses clés et mots de passe sont conservés.\n");exit(1);}
$values=['APP_ENV'=>'dev','PLATFORM_DOMAIN'=>'localhost','PLATFORM_PORT'=>'8080','APP_SECRET'=>bin2hex(random_bytes(32)),'PLATFORM_ENCRYPTION_KEY'=>bin2hex(random_bytes(32)),'PG_ADMIN_PASSWORD'=>bin2hex(random_bytes(32)),'PLATFORM_DB_PASSWORD'=>bin2hex(random_bytes(32)),'TRUSTED_PROXIES'=>''];
$handle=fopen($file,'x');if (!$handle) throw new RuntimeException('Création de configuration impossible.');chmod($file,0600);foreach ($values as $k=>$v) fwrite($handle,$k.'='.$v."\n");fclose($handle);
echo "Configuration locale PostgreSQL créée dans .env.platform (fichier privé).\nLancez : docker compose --env-file .env.platform -f deploy/compose.yaml up -d --build\n";
