Skip to content

Add support for PHP 8.x#96

Open
ara303 wants to merge 10 commits intoaaemnnosttv:masterfrom
ara303:fix/php-8.2-compat
Open

Add support for PHP 8.x#96
ara303 wants to merge 10 commits intoaaemnnosttv:masterfrom
ara303:fix/php-8.2-compat

Conversation

@ara303
Copy link

@ara303 ara303 commented Mar 15, 2026

Fixes #94.

This PR adds support for PHP 8.x versions by bumping dependency versions, and making some changes to tests so that they run under PHP 8.5 (latest stable).

Testing procedure

Tested with every minor 8.x version (8.0, 8.1, 8.2, 8.3, 8.4, and 8.5). Development and testing was done on 8.5.

Commands run on every version:

  • composer validate --strict
  • composer install
  • wp valet new <name>

Commands run on 8.5:

  • composer behat

Tests pass:

14 scenarios (14 passed)
104 steps (104 passed)
1m4.04s (11.96Mb)

PHP 8.5 notes

Because 8.5 is so recent, I needed to use the nightly build of WP-CLI to avoid (harmless) noise: wp cli update --nightly (version: WP-CLI 2.13.0-alpha-b0f2aec).

Additionally, one warning shown by composer install (and update):

Package roots/wp-password-bcrypt is abandoned, you should avoid using it. Use roots/wp-password-bcrypt instead.

roots/wp-password-bcrypt is abandoned now bcrypt is in WP core as of 6.8. We need to just ignore that for the time being.

Changes made to tests

I tried to run the tests under every minor PHP 8.x version but couldn't due to dependency issues. PHP 8.0 and 8.1 (both now EOL) couldn't run it at all, but I made sure wp valet new <name> works on every 8.x version.

For the Bedrock tests, $_SERVER env vars weren't returning and those tests failed. I fixed that by using getenv() instead.

Due to being unfamiliar with SQLite, I got stuck here:

Deprecated: Method PDO::sqliteCreateFunction() is deprecated since 8.5, use Pdo\Sqlite::createFunction() instead in /private/var/folders/yf/vrmrf8mn2kz37pczv36rw8z80000gn/T/wp-cli-test-run--69b8ac214eea05.46297354/valet-test-69b8ac214f7df/web/app/db.php on line 155

I changed "run" to "try" to get it to pass, but it's... imperfect(!).

I see you made aaemnnosttv/wp-sqlite-db, which uses sqliteCreateFunction. I am happy to make a PR there to patch that, which means we can revert to "run" here and also require the new sqlite db package here. I'm happy to do it if you're okay with it? :)

Finally, I changed from a hardcoded mysql in features/Context/FeatureContext.php to a MYSQL_BINARY env var instead. My dev setup uses mariadb and the tests intermittently failed otherwise. This PR on wp-cli/wp-cli-tests was useful.

Major version bump?

Since these changes expressly require PHP 8.x or newer (composer require php >=8.0), I was wondering if you think this release should be tagged version 2.x, or similar? Let me know if you want me to merge into a different branch accordingly.

Thanks so much. 😄

@ara303 ara303 changed the title Bump composer requirements to support PHP >8.x Bump composer requirements to support PHP 8.x Mar 16, 2026
@ara303 ara303 mentioned this pull request Mar 16, 2026
@ara303 ara303 changed the title Bump composer requirements to support PHP 8.x Add support for PHP 8.x Mar 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

PHP 8.x support

1 participant