Skip to content

Add bundled php exts support #275

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 11 commits into
base: main
Choose a base branch
from

Conversation

asgrim
Copy link
Collaborator

@asgrim asgrim commented Jul 3, 2025

Fixes #133

@asgrim asgrim added this to the 1.1.0 milestone Jul 3, 2025
@asgrim asgrim self-assigned this Jul 3, 2025
@asgrim asgrim added the enhancement New feature or request label Jul 3, 2025
Copy link
Member

@TimWolla TimWolla left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Besides the remarks, I'm more generally concerned about this. As you can see for the extensions where you commented the build failures, the bundled extensions are not tested outside of PHP’s build system and it's probably easy to accidentally choose some different configure options that result in subtly broken extensions, especially when considering that Linux distributions often ship with patched PHP versions, where PIE is going to miss out on those patches. The bundled extensions really should just be installed by the respective package manager.

Comment on lines 61 to 76
[
'name' => 'opcache',
'type' => ExtensionType::ZendExtension,
'version' => '>= 5.5.0',
],
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This extension is always loaded.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Opcache (at least for now) can be disabled when compiling with --disable-opcache, so theoretically could be built as a shared extension, as I understand it?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, this meant to read "is always loaded with PHP 8.5". This is not yet the case, but will likely be with 8.5.0 Alpha 3 as part of https://wiki.php.net/rfc/make_opcache_required.

@asgrim
Copy link
Collaborator Author

asgrim commented Jul 7, 2025

@TimWolla

As you can see for the extensions where you commented the build failures, the bundled extensions are not tested outside of PHP’s build system

Yes, my plan here is to add an integration test that does a test pie install <package> for each of these defined ones. I'm working on that next so you'll see what I mean shortly

The bundled extensions really should just be installed by the respective package manager.

This was my expectation too, but we have had several requests, I think the most common would be PDO*, bcmath, mbstring.

@TimWolla
Copy link
Member

Yes, my plan here is to add an integration test that does a test pie install <package> for each of these defined ones. I'm working on that next so you'll see what I mean shortly

Just building extensions is not a sufficient guarantee that they'll work correctly. As an example MySQLnd relies on OpenSSL for the TLS support and trying to build MySQLnd in a standalone fashion is not unlikely to result in a version without TLS support, even when OpenSSL is loaded in PHP as a shared module.

@asgrim asgrim force-pushed the add-bundled-php-exts-support branch from ecfe93a to 255855a Compare July 15, 2025 21:35
@TimWolla
Copy link
Member

Besides the remarks, I'm more generally concerned about this.

To expand on this a little more: It would also make it easy to accidentally run subtly different patch versions of the bundled libraries, leading to confusion when reporting issues. Consider the following:

  • PHP installed via the package manager (8.2.28 at the time of writing for Debian Stable).
  • pdo_mysql installed via PIE (8.2.29 at the time of writing)
  • mysqlnd installed via PIE (8.2.25, because the user didn't update it)

Now a user finds a bug in the MySQL integration and reports it as “I'm using PHP 8.2.28” and folks are left confused, because the bug had already been fixed in MySQLnd with PHP 8.2.27, but the user didn't install the updated mysqlnd with PIE. Over time the versions will diverge further when half of the stuff was installed with the package manager and the other half with PIE. Or possibly some extension is installed with PIE and then later the corresponding package is installed with the package manager, leading to both the package manager and the PIE version being installed and fighting with each other.

Instead it would probably make sense to report a helpful message when running pie install pdo_mysql to indicate something like:

It seems you are running PHP installed via Debian’s packages. Use apt install php8.2-mysql to install pdo_mysql.

or

You are running in Docker, use docker-php-ext-install pdo_mysql

or similar.

TimWolla added a commit to TimWolla/php-src that referenced this pull request Jul 17, 2025
This constant can be handy for tools like PIE to determine the origin of a PHP
binary to provide better output / diagnostics.

see php/pie#275
see php#18168
'name' => 'ffi',
'require' => ['php' => '>= 7.4.0'],
],
// ['name' => 'gd'], // build failure - ext/gd/gd.c:79:11: fatal error: ft2build.h: No such file or directory
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can't work this one out. The required system dependencies seem to be installed, but this header still seems to be missing in CI.

@@ -105,6 +106,12 @@ public function extensionPath(): string
return $extensionPath;
}

// if the path is absolute, try to create it
// @todo error checking/squelching
if (mkdir($extensionPath, 0777, true) && file_exists($extensionPath) && is_dir($extensionPath)) {
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixes #263

- '8.2'
- '8.3'
- '8.4'
#- '8.5' # @todo enable
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tracking this todo

@@ -105,6 +106,12 @@ public function extensionPath(): string
return $extensionPath;
}

// if the path is absolute, try to create it
// @todo error checking/squelching
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tracking this todo

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Make core bundled extensions available (PDO, curl, intl, etc.)
2 participants