.env file was found, and no APP_KEY is set in this ' .'environment. ProjectSend needs an application key before it can start.', "Copy the example configuration, then generate the key:\n\n" ."cp .env.example .env\nphp artisan key:generate", ]; } return [ 'ProjectSend is not configured yet', 'A .env file is present, but its APP_KEY is empty. ProjectSend ' .'needs an application key before it can start.', "Generate the key:\n\nphp artisan key:generate", ]; } /** * Render the message and stop, or return so Laravel can take over. * * Called with no argument from public/index.php; the argument exists so * tests can point it at a fixture directory. */ function projectsend_preflight(?string $root = null): void { $failure = projectsend_preflight_failure($root ?? dirname(__DIR__)); if ($failure === null) { return; } [$title, $reason, $fix] = $failure; // 503, not 500: the install is temporarily unavailable pending setup, // not broken. Retry-After keeps a well-behaved proxy or uptime check // from hammering it while someone finishes the install. if (! headers_sent()) { http_response_code(503); header('Content-Type: text/html; charset=UTF-8'); header('Retry-After: 3600'); header('Cache-Control: no-store'); } $e = static fn (string $s): string => htmlspecialchars($s, ENT_QUOTES, 'UTF-8'); echo '' .'' .''.$e($title).'
' .'

'.$e($title).'

' .'

'.$reason.'

' .'

'.$e(projectsend_preflight_intro($fix)).'

' .'
'.$e(projectsend_preflight_command($fix)).'
' .'

Run these as the user your web server runs as. ' .'The full procedure is in INSTALL.md.

' .'
'; exit; } /** * The sentence before the command block in a fix string. */ function projectsend_preflight_intro(string $fix): string { return trim(explode("\n\n", $fix, 2)[0]); } /** * The command block from a fix string. */ function projectsend_preflight_command(string $fix): string { $parts = explode("\n\n", $fix, 2); return trim($parts[1] ?? $parts[0]); } // Auto-run when included by the front controller; suppressed under test so // the pure helpers above can be exercised against fixtures. if (! defined('PROJECTSEND_PREFLIGHT_TEST')) { projectsend_preflight(); }