Skip to content

Commit c02cc6c

Browse files
chapterjasonclaude
andcommitted
Drop dev-oriented php.ini overrides
Sury ships production defaults — errors silent, display_errors off, memory_limit capped. Fine in prod, actively harmful in a dev workspace where you want failures loud and iterative scripts unconstrained. New scripts/php/workspace.ini sets error_reporting=E_ALL, display_errors on, memory_limit=-1, max_execution_time=0, opcache.enable_cli=1, UTC timezone. Staged at /usr/local/share/php-workspace/ by the root installer, then copied into every SAPI conf.d (99- prefix so it wins over Sury's defaults) of the default version at build time. pvm's install subcommand reuses the staged file so every additional version picks up the same overrides. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 152a737 commit c02cc6c

3 files changed

Lines changed: 40 additions & 1 deletion

File tree

scripts/php/install.sh

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,22 @@ fi
4343
apt-get install -y --no-install-recommends --no-install-suggests $pkgs
4444
rm -rf /var/lib/apt/lists/*
4545

46+
script_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
47+
48+
# Dev-oriented php.ini overrides. Staged at a known path so pvm can reuse
49+
# it when installing additional PHP versions later.
50+
install -m 0755 -d /usr/local/share/php-workspace
51+
install -m 0644 "$script_dir/workspace.ini" /usr/local/share/php-workspace/workspace.ini
52+
53+
# Apply to every SAPI (cli, fpm, apache2, ...) of the default version that
54+
# got installed. 99- prefix so it loads last and wins over Sury defaults.
55+
for sapi_dir in /etc/php/"$PHP_DEFAULT_VERSION"/*/conf.d; do
56+
[ -d "$sapi_dir" ] || continue
57+
install -m 0644 /usr/local/share/php-workspace/workspace.ini "$sapi_dir/99-workspace.ini"
58+
done
59+
4660
# pvm — user-level PHP version switcher. Lives next to this installer; see
4761
# scripts/php/pvm for the script body.
48-
script_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
4962
install -m 0755 "$script_dir/pvm" /usr/local/bin/pvm
5063

5164
if ! command -v php >/dev/null 2>&1; then

scripts/php/pvm

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,17 @@ cmd_install() {
129129
fi
130130
# shellcheck disable=SC2086
131131
sudo apt-get install -y --no-install-recommends --no-install-suggests $pkgs
132+
133+
# Layer the staged workspace overrides (dev errors, no memory cap, ...)
134+
# over every SAPI dir this version created. Staged by scripts/php/install.sh
135+
# at image build time.
136+
if [ -r /usr/local/share/php-workspace/workspace.ini ]; then
137+
for sapi_dir in /etc/php/"$ver"/*/conf.d; do
138+
[ -d "$sapi_dir" ] || continue
139+
sudo install -m 0644 /usr/local/share/php-workspace/workspace.ini "$sapi_dir/99-workspace.ini"
140+
done
141+
fi
142+
132143
echo "PHP $ver installed. Activate with: pvm use $ver"
133144
}
134145

scripts/php/workspace.ini

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
; Dev-oriented PHP overrides for workspace use. Sury ships production
2+
; defaults (errors silent, constrained memory) which are actively harmful
3+
; when iterating on code. Surface errors loudly, lift limits. Applied on
4+
; top of the SAPI-default conf.d via the 99- prefix so we win over Sury's
5+
; own files. Installed for every SAPI of every version present —
6+
; scripts/php/install.sh does it at build time, pvm does it when
7+
; installing extra versions.
8+
error_reporting = E_ALL
9+
display_errors = On
10+
display_startup_errors = On
11+
log_errors = On
12+
memory_limit = -1
13+
max_execution_time = 0
14+
date.timezone = UTC
15+
opcache.enable_cli = 1

0 commit comments

Comments
 (0)