[DOC-CVS] [doc-en] master: Follow up with Dev Container improvements (#5615)
[email protected] (Jordi Kroon via GitHub) Thu, 2 Jul 2026 16:29:42 +0000
| Newsgroups | php.doc.cvs |
|---|---|
| Message-ID | <[email protected]> |
Author: Jordi Kroon (jordikroon)
Committer: GitHub (web-flow)
Pusher: jordikroon
Date: 2026-07-02T18:29:40+02:00
Commit: https://github.com/php/doc-en/commit/cf958900236d712c55aa4dbd585fc0ba3b04fe7a
Raw diff: https://github.com/php/doc-en/commit/cf958900236d712c55aa4dbd585fc0ba3b04fe7a.diff
Follow up with Dev Container improvements (#5615)
* Follow up with Dev Container improvements
* Fix assets behind a different URL
* Remove PHP server prepend file and JAVA_OPTIONS config
* Add PHP server prepend file as codespaces uses HTTP_X_FORWARDED_X
Changed paths:
A .devcontainer/server-prepend.php
M .devcontainer/build.sh
M .devcontainer/post-create.sh
Diff:
diff --git a/.devcontainer/build.sh b/.devcontainer/build.sh
index 456a66ab6815..367f4efab145 100755
--- a/.devcontainer/build.sh
+++ b/.devcontainer/build.sh
@@ -5,16 +5,11 @@ set -e
FORMAT="${1:-xhtml}"
case "$FORMAT" in
- xhtml) OUTDIR="output/php-chunked-xhtml" ;;
- php) OUTDIR="output/php-web" ;;
+ xhtml) DOCROOT="output/php-chunked-xhtml" ;;
+ php) DOCROOT="../web-php" ;;
*) echo "Usage: $0 [xhtml|php]" >&2; exit 1 ;;
esac
- # doc-base invokes `java -jar jing.jar` with no flags, so the only handle on
- # the JAXP entity-size limit is the JVM env vars. The PHP manual is well past
- # the 100k default and we have no other way to lift the limit.
- export _JAVA_OPTIONS='-Djdk.xml.totalEntitySizeLimit=0 -Djdk.xml.entityExpansionLimit=0 -Djdk.xml.maxGeneralEntitySizeLimit=0'
-
php ../doc-base/configure.php \
--disable-libxml-check \
--enable-xml-details \
@@ -27,5 +22,25 @@ php -d memory_limit=512M ../phd/render.php \
--package PHP \
--format "$FORMAT"
+# Restart any existing server, then launch the new one in its own session so
+# Ctrl+C in the debug terminal only kills the log tail below. The server keeps
+# running until the next build replaces it (or the container shuts down).
+#
+# auto_prepend_file rewrites $_SERVER from the request's Host header so the PHP
+# format's $MYSITE-built URLs work behind Codespaces / other port forwarders.
+LOG="/tmp/php-server-${FORMAT}.log"
pkill -f 'php -S 0.0.0.0:8080' 2>/dev/null || true
-exec php -S 0.0.0.0:8080 -t "$OUTDIR"
+PREPEND="$(cd "$(dirname "$0")" && pwd)/server-prepend.php"
+setsid nohup php -d "auto_prepend_file=$PREPEND" -S 0.0.0.0:8080 -t "$DOCROOT" \
+ >"$LOG" 2>&1 </dev/null &
+SERVER_PID=$!
+
+cat <<EOF
+
+ Server: http://localhost:8080 (pid $SERVER_PID, doc root: $DOCROOT)
+ Logs: $LOG
+ Ctrl+C exits this tail; the server keeps running.
+
+EOF
+
+exec tail -f "$LOG"
diff --git a/.devcontainer/post-create.sh b/.devcontainer/post-create.sh
index 2ea8a6764a2f..2f9eb808dc0f 100755
--- a/.devcontainer/post-create.sh
+++ b/.devcontainer/post-create.sh
@@ -6,9 +6,10 @@ WORKSPACE="$(cd "$(dirname "$0")/.." && pwd)"
PARENT="$(dirname "$WORKSPACE")"
OWNER="$(stat -c '%U' "$WORKSPACE")"
-# Clone doc-base and phd as siblings of doc-en
+# Clone doc-base, phd, and web-php as siblings of doc-en.
[ -d "$PARENT/doc-base" ] || sudo -u "$OWNER" git -C "$PARENT" clone --depth 1 https://github.com/php/doc-base.git
[ -d "$PARENT/phd" ] || sudo -u "$OWNER" git -C "$PARENT" clone --depth 1 https://github.com/php/phd.git
+[ -d "$PARENT/web-php" ] || sudo -u "$OWNER" git -C "$PARENT" clone --depth 1 https://github.com/php/web-php.git
# doc-base's configure.php looks for the language source as a sibling directory
[ -e "$PARENT/en" ] || sudo -u "$OWNER" ln -s "$WORKSPACE" "$PARENT/en"
@@ -16,8 +17,10 @@ OWNER="$(stat -c '%U' "$WORKSPACE")"
# Xdebug degrades performance and is not needed for the build, so disable it by default.
rm -f /usr/local/etc/php/conf.d/xdebug.ini
-# Pre-create the served directory
-sudo -u "$OWNER" mkdir -p "$WORKSPACE/output/php-chunked-xhtml"
+# Pre-create the served directories
+sudo -u "$OWNER" mkdir -p "$WORKSPACE/output/php-chunked-xhtml" "$WORKSPACE/output/php-web"
+sudo -u "$OWNER" rm -rf "$PARENT/web-php/manual/en"
+sudo -u "$OWNER" ln -s "$WORKSPACE/output/php-web" "$PARENT/web-php/manual/en"
cat <<'EOF'
diff --git a/.devcontainer/server-prepend.php b/.devcontainer/server-prepend.php
new file mode 100644
index 000000000000..658e6f31edbb
--- /dev/null
+++ b/.devcontainer/server-prepend.php
@@ -0,0 +1,15 @@
+<?php
+
+// This file rewrites $_SERVER from the request's Host header so the PHP
+// format's $MYSITE-built URLs work behind Codespaces / other port forwarders.
+
+$forwardedHttps = ($_SERVER['HTTP_X_FORWARDED_PROTO'] ?? '') === 'https';
+$hostHeader = $_SERVER['HTTP_X_FORWARDED_HOST'] ?? $_SERVER['HTTP_HOST'] ?? '';
+
+if ($hostHeader !== '') {
+ $_SERVER['HTTP_HOST'] = $hostHeader;
+}
+
+if ($forwardedHttps) {
+ $_SERVER['HTTPS'] = 'on';
+}