PHP – Standalone PWA

<?php
/**
 * Spaceman - Standalone PWA 
 */

if (isset($_GET['manifest'])) {
    header('Content-Type: application/manifest+json');
    echo json_encode([
        "name" => "Spaceman",
        "short_name" => "Spaceman",
        "start_url" => "index.php",
        "display" => "standalone",
        "background_color" => "#000000",
        "theme_color" => "#00f2ff",
        "icons" => [["src" => "fav.png", "sizes" => "512x512", "type" => "image/png"]]
    ]);
    exit;
}

if (isset($_GET['sw'])) {
    header('Content-Type: application/javascript');
    echo "self.addEventListener('fetch', e => e.respondWith(fetch(e.request)));";
    exit;
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no, viewport-fit=cover">
    <title>Spaceman</title>
    <link rel="manifest" href="?manifest=1">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="theme-color" content="#00f2ff">