Last active
September 18, 2020 08:38
-
-
Save banasmat/ef87cd236e248b6287337b6ba30df5c0 to your computer and use it in GitHub Desktop.
Symfony local server simple supervisor and rewrite (router)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
:: Simple supervisor that restarts local symfony server automatically if stopped for any reason | |
:: Place in symfony-project's root dir | |
:: Start server with: auto-restart.bat | |
:while_loop | |
curl localhost:8000 | |
if errorlevel == 7 ( | |
:: restarting server | |
symfony server:stop | |
symfony server:start --passthru local-router.php --document-root public -d --port 8000 -d | |
) | |
timeout 10 | |
goto :while_loop |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Simple router for serving public asset files directly without passing through index.php | |
// Based on https://gist.github.com/rogeriopradoj/10645347 | |
// Place in symfony-project's public dir | |
// To be used only locally with command: symfony server:start --passthru router.php --document-root public | |
// Should not be deployed to production (can be gitignored) | |
if (preg_match('/\.(?:png|jpg|jpeg|gif|js|css)$/', strtok($_SERVER["REQUEST_URI"], '?'))) { | |
return false; | |
} else { | |
include __DIR__ . '/index.php'; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment