Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions DESIGN.md
Original file line number Diff line number Diff line change
Expand Up @@ -387,9 +387,9 @@ PV builds standalone PHP and FrankenPHP as single-binary/static-style artifacts

Standalone PHP artifacts include the `php` executable and runtime files needed by that build. They do not include `phpize` or `php-config` in v1 because user-built extensions are not supported.

The default loaded PHP extension set is Laravel-first and shared across supported PHP tracks: `bcmath`, `ctype`, `curl`, `dom`, `fileinfo`, `filter`, `hash`, `iconv`, `intl`, `json`, `libxml`, `mbstring`, `openssl`, `pcntl`, `pcre`, `pdo`, `pdo_mysql`, `pdo_pgsql`, `pdo_sqlite`, `phar`, `posix`, `session`, `simplexml`, `sockets`, `sodium`, `sqlite3`, `tokenizer`, `xml`, `xmlreader`, `xmlwriter`, `zip`, and `zlib`.
The default loaded PHP extension set is Laravel-first and shared across supported PHP tracks: `bcmath`, `ctype`, `curl`, `dom`, `fileinfo`, `filter`, `ftp`, `gd`, `hash`, `iconv`, `intl`, `json`, `libxml`, `mbstring`, `openssl`, `pcntl`, `pcre`, `pdo`, `pdo_mysql`, `pdo_pgsql`, `pdo_sqlite`, `phar`, `posix`, `session`, `simplexml`, `sockets`, `sodium`, `sqlite3`, `tokenizer`, `xml`, `xmlreader`, `xmlwriter`, `zip`, and `zlib`. GD includes FreeType, JPEG, AVIF, and WebP support.

The initial bundled optional extension catalog is `redis`, `sqlsrv`, `pdo_sqlsrv`, `xdebug`, `apcu`, `pcov`, `imagick`, `mongodb`, and `yaml`. Future optional extensions should be added only when users ask for them and PV can build, smoke-test, license, and support them across the intended PHP track and platform matrix.
The initial bundled optional extension catalog is `redis`, `sqlsrv`, `pdo_sqlsrv`, `xdebug`, `apcu`, `pcov`, `imagick`, `mongodb`, `yaml`, and `rar`. Future optional extensions should be added only when users ask for them and PV can build, smoke-test, license, and support them across the intended PHP track and platform matrix.

For a given PHP runtime identity, standalone PHP and FrankenPHP must expose the same loaded PHP extension set so CLI and browser execution do not drift.

Expand Down
2 changes: 2 additions & 0 deletions crates/pv-release/src/recipe.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ const REQUIRED_PHP_EXTENSIONS: &[&str] = &[
"dom",
"fileinfo",
"filter",
"ftp",
"gd",
"hash",
"iconv",
"intl",
Expand Down
24 changes: 12 additions & 12 deletions crates/pv-release/tests/recipe_fixtures.rs
Original file line number Diff line number Diff line change
Expand Up @@ -98,37 +98,37 @@ fn recipe_fixture_generation_validates_archives_records_and_manifest() -> Result
"frankenphp",
"8.3",
"darwin-amd64",
"frankenphp-8.3.31-frankenphp1.12.4-pv5-darwin-amd64",
"frankenphp-8.3.31-frankenphp1.12.4-pv6-darwin-amd64",
),
ArchiveRoot::new(
"frankenphp",
"8.3",
"darwin-arm64",
"frankenphp-8.3.31-frankenphp1.12.4-pv5-darwin-arm64",
"frankenphp-8.3.31-frankenphp1.12.4-pv6-darwin-arm64",
),
ArchiveRoot::new(
"frankenphp",
"8.4",
"darwin-amd64",
"frankenphp-8.4.22-frankenphp1.12.4-pv5-darwin-amd64",
"frankenphp-8.4.22-frankenphp1.12.4-pv6-darwin-amd64",
),
ArchiveRoot::new(
"frankenphp",
"8.4",
"darwin-arm64",
"frankenphp-8.4.22-frankenphp1.12.4-pv5-darwin-arm64",
"frankenphp-8.4.22-frankenphp1.12.4-pv6-darwin-arm64",
),
ArchiveRoot::new(
"frankenphp",
"8.5",
"darwin-amd64",
"frankenphp-8.5.7-frankenphp1.12.4-pv5-darwin-amd64",
"frankenphp-8.5.7-frankenphp1.12.4-pv6-darwin-amd64",
),
ArchiveRoot::new(
"frankenphp",
"8.5",
"darwin-arm64",
"frankenphp-8.5.7-frankenphp1.12.4-pv5-darwin-arm64",
"frankenphp-8.5.7-frankenphp1.12.4-pv6-darwin-arm64",
),
ArchiveRoot::new(
"mailpit",
Expand Down Expand Up @@ -178,12 +178,12 @@ fn recipe_fixture_generation_validates_archives_records_and_manifest() -> Result
"darwin-arm64",
"mysql-9.7.0-pv1-darwin-arm64"
),
ArchiveRoot::new("php", "8.3", "darwin-amd64", "php-8.3.31-pv5-darwin-amd64"),
ArchiveRoot::new("php", "8.3", "darwin-arm64", "php-8.3.31-pv5-darwin-arm64"),
ArchiveRoot::new("php", "8.4", "darwin-amd64", "php-8.4.22-pv5-darwin-amd64"),
ArchiveRoot::new("php", "8.4", "darwin-arm64", "php-8.4.22-pv5-darwin-arm64"),
ArchiveRoot::new("php", "8.5", "darwin-amd64", "php-8.5.7-pv5-darwin-amd64"),
ArchiveRoot::new("php", "8.5", "darwin-arm64", "php-8.5.7-pv5-darwin-arm64"),
ArchiveRoot::new("php", "8.3", "darwin-amd64", "php-8.3.31-pv6-darwin-amd64"),
ArchiveRoot::new("php", "8.3", "darwin-arm64", "php-8.3.31-pv6-darwin-arm64"),
ArchiveRoot::new("php", "8.4", "darwin-amd64", "php-8.4.22-pv6-darwin-amd64"),
ArchiveRoot::new("php", "8.4", "darwin-arm64", "php-8.4.22-pv6-darwin-arm64"),
ArchiveRoot::new("php", "8.5", "darwin-amd64", "php-8.5.7-pv6-darwin-amd64"),
ArchiveRoot::new("php", "8.5", "darwin-arm64", "php-8.5.7-pv6-darwin-arm64"),
ArchiveRoot::new(
"postgres",
"17",
Expand Down
15 changes: 8 additions & 7 deletions crates/pv-release/tests/recipe_metadata.rs
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ fn committed_recipe_metadata_parses() -> Result<()> {
ManifestDefaults::load(&workspace_root.join("release/artifacts/default-tracks.toml"))?;

assert_eq!(php.default_track().as_str(), "8.5");
assert_eq!(php.pv_build_revision(), "pv5");
assert_eq!(php.pv_build_revision(), "pv6");
assert_eq!(php.tracks().len(), 3);
assert_eq!(
php.tracks()
Expand Down Expand Up @@ -185,11 +185,10 @@ fn php_recipe_splits_default_and_optional_extensions() -> Result<()> {
let php = write_php_recipe(&tempdir)?;
let env = php_recipe_env(&php, "php", "8.4", "darwin-arm64")?;

let default_extensions =
"bcmath,curl,intl,mbstring,openssl,pcntl,pdo_mysql,pdo_pgsql,pdo_sqlite,sockets,sodium,zip";
let default_extensions = "bcmath,curl,ftp,gd,intl,mbstring,openssl,pcntl,pdo_mysql,pdo_pgsql,pdo_sqlite,sockets,sodium,zip";
assert!(env.contains(&format!("PV_DEFAULT_EXTENSIONS='{default_extensions}'")));
assert!(env.contains(
"PV_OPTIONAL_EXTENSIONS='redis,sqlsrv,pdo_sqlsrv,xdebug,apcu,pcov,imagick,mongodb,yaml'"
"PV_OPTIONAL_EXTENSIONS='redis,sqlsrv,pdo_sqlsrv,xdebug,apcu,pcov,imagick,mongodb,yaml,rar'"
));
assert!(env.contains(&format!("PV_BUILD_EXTENSIONS='{default_extensions}'")));
assert!(env.contains("PV_EXPECTED_EXTENSIONS='bcmath,ctype,curl"));
Expand Down Expand Up @@ -803,6 +802,8 @@ fn assert_php_staticphp_build_extensions(php: &PhpRecipe) {
"dom",
"fileinfo",
"filter",
"ftp",
"gd",
"iconv",
"intl",
"libxml",
Expand Down Expand Up @@ -896,9 +897,9 @@ notice_files = ["NOTICE"]

[php]
deployment_target = "13.0"
default_extensions = ["bcmath", "curl", "intl", "mbstring", "openssl", "pcntl", "pdo_mysql", "pdo_pgsql", "pdo_sqlite", "sockets", "sodium", "zip"]
optional_extensions = ["redis", "sqlsrv", "pdo_sqlsrv", "xdebug", "apcu", "pcov", "imagick", "mongodb", "yaml"]
expected_extensions = ["bcmath", "ctype", "curl", "dom", "fileinfo", "filter", "hash", "iconv", "intl", "json", "libxml", "mbstring", "openssl", "pcntl", "pcre", "pdo", "pdo_mysql", "pdo_pgsql", "pdo_sqlite", "phar", "posix", "session", "simplexml", "sockets", "sodium", "sqlite3", "tokenizer", "xml", "xmlreader", "xmlwriter", "zip", "zlib"]
default_extensions = ["bcmath", "curl", "ftp", "gd", "intl", "mbstring", "openssl", "pcntl", "pdo_mysql", "pdo_pgsql", "pdo_sqlite", "sockets", "sodium", "zip"]
optional_extensions = ["redis", "sqlsrv", "pdo_sqlsrv", "xdebug", "apcu", "pcov", "imagick", "mongodb", "yaml", "rar"]
expected_extensions = ["bcmath", "ctype", "curl", "dom", "fileinfo", "filter", "ftp", "gd", "hash", "iconv", "intl", "json", "libxml", "mbstring", "openssl", "pcntl", "pcre", "pdo", "pdo_mysql", "pdo_pgsql", "pdo_sqlite", "phar", "posix", "session", "simplexml", "sockets", "sodium", "sqlite3", "tokenizer", "xml", "xmlreader", "xmlwriter", "zip", "zlib"]

[frankenphp]
version = "1.12.3"
Expand Down
158 changes: 153 additions & 5 deletions crates/pv-release/tests/smoke.rs
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,8 @@ case "${1:-}" in
elif [ "$code" = 'foreach (get_loaded_extensions() as $extension) { echo $extension, PHP_EOL; }' ]; then
printf '%s\n' 'php-cli -r extensions' >>"$PV_FRANKENPHP_LOG"
printf '%s\n' 'json'
elif printf '%s' "$code" | grep -F 'gd_info()' >/dev/null; then
printf '%s\n' 'php-cli -r capabilities' >>"$PV_FRANKENPHP_LOG"
else
exit 99
fi
Expand Down Expand Up @@ -168,7 +170,7 @@ exit 28
assert!(status.success(), "smoke hook exited with {status}");
let frankenphp_log = read_file(&frankenphp_log)?;
assert!(frankenphp_log.starts_with(
"php-cli -r version\nphp-cli -r extensions\nphp-cli -r mbregex\nphp-server 127.0.0.1:"
"php-cli -r version\nphp-cli -r extensions\nphp-cli -r mbregex\nphp-cli -r capabilities\nphp-server 127.0.0.1:"
));
assert!(
frankenphp_log.contains(" phpinfo\n"),
Expand Down Expand Up @@ -223,6 +225,8 @@ case "${1:-}" in
exit 0
elif [ "$code" = 'foreach (get_loaded_extensions() as $extension) { echo $extension, PHP_EOL; }' ]; then
printf '%s\n' 'json'
elif printf '%s' "$code" | grep -F 'gd_info()' >/dev/null; then
exit 0
else
exit 99
fi
Expand Down Expand Up @@ -369,6 +373,116 @@ esac
Ok(())
}

#[test]
fn php_smoke_requires_default_runtime_capabilities() -> Result<()> {
let tempdir = tempdir()?;
let artifact_root = tempdir.path().join("artifact");
let artifact_bin = artifact_root.join("bin");

create_dir_all(&artifact_bin)?;
write_executable(
&artifact_bin.join("php"),
r#"#!/bin/sh
set -eu
case "$1" in
-v) printf '%s\n' 'PHP 8.4.20 (cli)' ;;
-m) printf '%s\n' 'json' ;;
-r)
[ "${2:-}" = 'exit(function_exists("mb_split") ? 0 : 1);' ] || exit 1
;;
*) exit 99 ;;
esac
"#,
)?;

let output = StdCommand::new(php_smoke_hook())
.arg(&artifact_root)
.env("PATH", "/usr/bin:/bin:/usr/sbin:/sbin")
.env("PV_EXPECTED_EXTENSIONS", "json")
.env("PV_UPSTREAM_VERSION", "8.4.20")
.output()?;

assert!(
!output.status.success(),
"smoke hook should require default runtime capabilities: {}",
command_output_debug(&output)
);
assert_eq!(output.status.code(), Some(48));
assert!(
String::from_utf8_lossy(&output.stderr)
.contains("missing required PHP runtime capability: SQLite3, FTP, or GD codecs"),
"smoke hook should identify the missing runtime capability: {}",
command_output_debug(&output)
);

Ok(())
}

#[test]
fn php_smoke_requires_rar_archive_capability() -> Result<()> {
let tempdir = tempdir()?;
let artifact_root = tempdir.path().join("artifact");
let artifact_bin = artifact_root.join("bin");
let metadata_dir = artifact_root.join("share/pv");
let extension_dir = artifact_root.join("lib/php/extensions");

create_dir_all(&artifact_bin)?;
create_dir_all(&metadata_dir)?;
create_dir_all(&extension_dir)?;
write_file(
&artifact_root.join("share/pv/php-extensions.json"),
r#"[{"name":"rar","load_kind":"extension","path":"lib/php/extensions/rar.so"}]"#,
)?;
write_file(
&artifact_root.join("lib/php/extensions/rar.so"),
"rar module\n",
)?;
write_executable(
&artifact_bin.join("php"),
r#"#!/bin/sh
set -eu
case "$1" in
-v) printf '%s\n' 'PHP 8.4.20 (cli)' ;;
-m) printf '%s\n' 'json' ;;
-r)
code=${2:-}
case "$code" in
'foreach (get_loaded_extensions() as $extension) { echo $extension, PHP_EOL; }')
printf '%s\n' 'json' 'rar'
;;
'exit(class_exists("RarArchive") ? 0 : 1);')
exit 1
;;
esac
;;
*) exit 99 ;;
esac
"#,
)?;

let output = StdCommand::new(php_smoke_hook())
.arg(&artifact_root)
.env("PATH", "/usr/bin:/bin:/usr/sbin:/sbin")
.env("PV_EXPECTED_EXTENSIONS", "json")
.env("PV_UPSTREAM_VERSION", "8.4.20")
.output()?;

assert!(
!output.status.success(),
"smoke hook should require RarArchive: {}",
command_output_debug(&output)
);
assert_eq!(output.status.code(), Some(49));
assert!(
String::from_utf8_lossy(&output.stderr)
.contains("missing optional PHP runtime capability: RarArchive"),
"smoke hook should identify the missing RAR capability: {}",
command_output_debug(&output)
);

Ok(())
}

#[test]
fn php_smoke_allows_extra_extensions() -> Result<()> {
let tempdir = tempdir()?;
Expand Down Expand Up @@ -461,7 +575,14 @@ case "$1" in
printf '%s\n' 'json'
fi
;;
-r) exit 0 ;;
-r)
if [ -n "${PHP_INI_SCAN_DIR:-}" ] \
&& grep -R -F "extension=$PV_TEST_ARTIFACT_ROOT/lib/php/extensions/redis.so" "$PHP_INI_SCAN_DIR" >/dev/null \
&& grep -R -F "zend_extension=$PV_TEST_ARTIFACT_ROOT/lib/php/extensions/xdebug.so" "$PHP_INI_SCAN_DIR" >/dev/null; then
printf '%s\n' optional >>"$PV_TEST_PHP_SMOKE_LOG"
printf '%s\n' 'json' 'redis' 'xdebug'
fi
;;
*) exit 99 ;;
esac
"#,
Expand Down Expand Up @@ -612,6 +733,8 @@ case "${1:-}" in
exit 0
elif [ "$code" = 'foreach (get_loaded_extensions() as $extension) { echo $extension, PHP_EOL; }' ]; then
printf '%s\n' 'json'
elif printf '%s' "$code" | grep -F 'gd_info()' >/dev/null; then
exit 0
else
exit 99
fi
Expand Down Expand Up @@ -714,7 +837,7 @@ printf '%s\n' 'Composer version 2.10.10 2026-01-01 00:00:00'
#[test]
fn php_build_recipe_smoke() -> Result<()> {
let run = run_php_build_recipe_smoke_with_options(BuildRecipeOptions {
php_optional_extensions: "redis,xdebug,imagick",
php_optional_extensions: "redis,xdebug,imagick,rar",
..default_build_recipe_options()
})?;
let php_source_dir = format!("{}/sources/php-8.4.20-source/php-source", run.out_dir);
Expand All @@ -736,7 +859,7 @@ spc-cflags=-I{imagick_include}\n\
spc-cxxflags=-I{imagick_include}\n\
spc-pkg-config=pkg-config\n\
spc-pkg-config-libdir={pkg_config_libdir}\n\
argv=[build:php][json,mbregex][--build-shared=redis,xdebug,imagick][--build-cli][--build-frankenphp][--enable-zts][--with-config-file-path=/var/empty/com.prvious.pv/php][--with-config-file-scan-dir=/var/empty/com.prvious.pv/php/conf.d][--dl-with-php=8.4.20][--dl-retry=3][--dl-custom-local][php-src:{php_source_dir}][--dl-custom-local][frankenphp:{frankenphp_source_dir}]\n",
argv=[build:php][json,mbregex][--build-shared=redis,xdebug,imagick,rar][--with-libs=freetype,libjpeg,libavif,libwebp][--build-cli][--build-frankenphp][--enable-zts][--with-config-file-path=/var/empty/com.prvious.pv/php][--with-config-file-scan-dir=/var/empty/com.prvious.pv/php/conf.d][--dl-with-php=8.4.20][--dl-retry=3][--dl-custom-local][php-src:{php_source_dir}][--dl-custom-local][frankenphp:{frankenphp_source_dir}]\n",
run.out_dir
);

Expand All @@ -758,11 +881,36 @@ argv=[-L][--fail][--show-error][--silent][--retry][3][--retry-delay][2][--retry-
);
assert_eq!(run.curl_log, expected_curl_log);
assert!(run.php_record_json.is_some(), "PHP record was not written");
assert!(run.php_notice.is_some(), "PHP NOTICE was not written");
assert_eq!(
build_recipe_record_php_extension_names(run.php_record_json.as_deref())?,
vec!["imagick", "rar", "redis", "xdebug"]
);
for (resource, notice) in [
("PHP", run.php_notice.as_deref()),
("FrankenPHP", run.frankenphp_notice.as_deref()),
] {
let notice = notice.ok_or_else(|| anyhow::anyhow!("{resource} NOTICE was not written"))?;
assert!(
notice.contains("UnRAR code is copyright Alexander L. Roshal"),
"{resource} NOTICE omitted the UnRAR attribution"
);
assert!(
notice.contains("develop a RAR (WinRAR) compatible archiver"),
"{resource} NOTICE omitted the RAR-compatible archiver restriction"
);
assert!(
notice.contains("re-create the RAR compression algorithm"),
"{resource} NOTICE omitted the RAR compression restriction"
);
}
assert!(
run.frankenphp_record_json.is_some(),
"FrankenPHP record was not written"
);
assert_eq!(
build_recipe_record_php_extension_names(run.frankenphp_record_json.as_deref())?,
vec!["imagick", "rar", "redis", "xdebug"]
);
assert!(run.php_archive_exists, "PHP archive was not written");
assert!(
run.frankenphp_archive_exists,
Expand Down
Loading
Loading