mirror of
https://codeberg.org/PostERG/xamxam.git
synced 2026-05-06 19:19:19 +02:00
feat: single entry point routing — convert to front controller pattern
- Create app/public/index.php as front controller (bootstrap + Dispatcher) - Rewrite app/router.php for PHP dev server → all non-asset requests to index.php - Update Dispatcher to render full page layouts (head+header+view+footer) - Move public view templates into templates/public/ (home, search, tfe, about, repertoire) - Delete dead direct-access public/*.php files (apropos, search, tfe, licence, repertoire) - Add clean URL routes to Dispatcher (/search, /tfe, /repertoire, /apropos, /licence, /media) - Remove .php extensions from all internal links (header, views, templates, URLs) - Update OG tags in controllers to use clean URLs - Update nginx posterg.conf → front-controller try_files pattern, block direct .php access - Update header.php and search-bar.php form actions to clean URLs - Switch AboutController nav key from 'nav' to 'currentNav' for consistency
This commit is contained in:
@@ -2,25 +2,19 @@
|
||||
/**
|
||||
* Router script for PHP built-in development server (php -S).
|
||||
*
|
||||
* Routes /partage/<slug> to public/partage/index.php, since the built-in
|
||||
* server has no URL rewriting like nginx's try_files.
|
||||
* All non-asset requests go through the front controller (public/index.php).
|
||||
* Static files (CSS, JS, images, fonts) are served directly.
|
||||
*/
|
||||
|
||||
$uri = parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH);
|
||||
|
||||
// Route /partage/<slug> and /partage/<slug>/<action> to the partage entry
|
||||
if (preg_match('#^/partage(/.*)?$#', $uri)) {
|
||||
$_SERVER['SCRIPT_NAME'] = '/partage/index.php';
|
||||
require __DIR__ . '/public/partage/index.php';
|
||||
return true;
|
||||
// Static assets: let the dev server handle them directly
|
||||
$ext = pathinfo($uri, PATHINFO_EXTENSION);
|
||||
if (in_array($ext, ['css', 'js', 'png', 'jpg', 'jpeg', 'gif', 'ico', 'svg', 'woff', 'woff2', 'ttf', 'eot', 'map'], true)) {
|
||||
return false; // serve directly
|
||||
}
|
||||
|
||||
// Route /tfe/<...> to tfe.php
|
||||
if (preg_match('#^/tfe(/.*)?$#', $uri)) {
|
||||
$_SERVER['SCRIPT_NAME'] = '/tfe.php';
|
||||
require __DIR__ . '/public/tfe.php';
|
||||
return true;
|
||||
}
|
||||
|
||||
// Default: serve static files if they exist
|
||||
return false;
|
||||
// Send everything else through the front controller
|
||||
$_SERVER['SCRIPT_NAME'] = '/index.php';
|
||||
require __DIR__ . '/public/index.php';
|
||||
return true;
|
||||
|
||||
Reference in New Issue
Block a user