ht.router.php can only be used in the root directory

Created on 13 February 2023, almost 2 years ago

Problem/Motivation

The core/assets/scaffold/files/ht.router.php file can only be used in root directory as the usage in document "php -S localhost:8888 .ht.router.php" and will have problems with "php -S localhost:8000 -t web/".

Example:
http://localhost:8000/admin/modules
Uncaught PHP Exception Twig\Error\LoaderError: "Template "core/modules/system/templates/input.html.twig"

Steps to reproduce

Install Drupal following the standard "composer create-project drupal/recommended-project drupal" and try to run PHP build in server without cd to drupal/web/ directory "php -S localhost:8000 -t web/ web/.ht.router.php".

Proposed resolution

Use $_SERVER['DOCUMENT_ROOT'] instead of __DIR__ to support PHP document root directory parameter "-t".

< if (file_exists(__DIR__ . $url['path'])) {
---
> if (file_exists($_SERVER['DOCUMENT_ROOT'] . $url['path'])) {
🐛 Bug report
Status

Active

Version

10.1

Component
Base 

Last updated about 19 hours ago

Created by

🇬🇧United Kingdom shenzhuxi

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Production build 0.71.5 2024