Skip to content

Modernize for PHP 8.1–8.5, republish as maksimovic/oauth2-server-php#2

Merged
maksimovic merged 30 commits into
mainfrom
php85
Apr 20, 2026
Merged

Modernize for PHP 8.1–8.5, republish as maksimovic/oauth2-server-php#2
maksimovic merged 30 commits into
mainfrom
php85

Conversation

@maksimovic

@maksimovic maksimovic commented Apr 20, 2026

Copy link
Copy Markdown
Owner

Republishes the library as maksimovic/oauth2-server-php and brings in the full PHP 8.5 modernization that has been sitting unanswered in bshaffer/oauth2-server-php#1088 for a month. The replace directive keeps it a drop-in for any consumer still requiring bshaffer/oauth2-server-php.

composer.json

  • Rename to maksimovic/oauth2-server-php, add "replace": {"bshaffer/oauth2-server-php": "*"}
  • php: ^8.1
  • phpunit/phpunit ^10.5, phpstan/phpstan ^2.1
  • firebase/php-jwt ^7.0, drop yoast/phpunit-polyfills
  • aws/aws-sdk-php ^3.0, predis/predis ^2.0, mroosz/php-cassandra ^1.2
  • mongodb/mongodb moved from require-dev to suggest
  • Add test, test:coverage, analyze composer scripts

CI

  • Docker-based matrix (PHP 8.1–8.5) using custom images with ext-couchbase pre-installed (.docker/Dockerfile + docker.yml workflow, weekly rebuild, GHA layer caching)
  • Services: Redis, MongoDB, MariaDB, Postgres, Cassandra, DynamoDB Local, Couchbase
  • Wire PDO-based Postgres setup; Cassandra + DynamoDB started in background for faster CI
  • GHCR namespace pinned for cross-repo forks

Source

  • Drop legacy src/OAuth2/Storage/Mongo.php (replaced by MongoDB SDK 4.x users)
  • Modernize CouchbaseDB storage for Couchbase SDK 4.x; add stubs/couchbase.stub for PHPStan
  • Fix CouchbaseDB::unsetAccessToken — return false for missing tokens, add missing method
  • Fix DynamoDB public-key methods — guard against null client_id
  • Update Cassandra storage to current driver APIs

Tests

  • Migrate to PHPUnit 10 (static data providers, schema, assertion API)
  • Fix JwtAccessTokenTest to check PublicKeyInterface rather than concrete PublicKey
  • Resolve a crop of deprecation warnings across the storage/controller test suite
  • Add phpstan.neon

Stats

42 files changed, +944 / -1413 — most of the removals are the deprecated Mongo driver and legacy Cassandra code.

- Require PHP ^8.1, CI matrix now tests 8.1-8.5
- Upgrade phpunit/phpunit ^9.6 to ^10.5 (convert @dataProvider to
  #[DataProvider] attributes, static data providers, update phpunit.xml)
- Upgrade aws/aws-sdk-php ^2.8 to ^3.0 (rewrite DynamoDB storage for
  v3 API: Marshaler, Result, lazy credential handling)
- Upgrade predis/predis ^1.1 to ^2.0 (fix getPayload() compat)
- Upgrade firebase/php-jwt ^6.4 to ^6.4 || ^7.0 (v7 requires 2048-bit
  RSA keys; all test keypairs regenerated)
- Replace Cassandra storage: swap abandoned thobbs/phpcassa (Thrift) for
  mroosz/php-cassandra ^1.2 (CQL native protocol, PHP 8.1+)
- Fix CI: bump to actions/checkout@v5, drop unmaintained retry action,
  fix MariaDB service config, add health checks, add Cassandra service,
  add pdo_pgsql extension
…ocal to CI

Remove Mongo.php (dead PHP 5.x MongoClient code; MongoDB.php remains).
Rewrite CouchbaseDB.php for Couchbase SDK 4.x (Cluster/Collection API).
Replace AWS credentials/Travis logic with DynamoDB Local in CI.
…ix DynamoDB health check

Use bash /dev/tcp for DynamoDB Local health check since the image
has no curl or wget. Narrow php-jwt to ^7.0 and remove the polyfills
package which is unnecessary on PHPUnit 10.
Add composer test, test:coverage, and analyze scripts. Enable verbose
PHPUnit output for deprecations, warnings, and skip reasons. CI now
uses the composer scripts.
Move Cassandra and DynamoDB out of services block so they start in
parallel with PHP setup and composer install instead of blocking the
entire job. Cassandra takes ~70s to boot; this now overlaps with the
~20s of checkout + PHP setup + composer install.
Eliminates psql client/server version mismatch errors (daticulocale)
and createdb failures when the database already exists from the Docker
service POSTGRES_DB env var.
- Replace deprecated 'self::isNotEmpty' callable strings with
  first-class callable syntax in DynamoDB storage
- Use 127.0.0.1 instead of localhost for MySQL to force TCP connection
  to Docker service (localhost uses Unix socket on Linux)
- Add mongodb/mongodb to require-dev so MongoDB tests run in CI
- Check extension_loaded('mongodb') before class_exists to avoid
  fatal errors when library is present but extension is not
Start couchbase:community-7.6.5 as a background container, initialize
the cluster with kv service, create the oauth2test bucket, and install
ext-couchbase via shivammathur/setup-php. This eliminates the last
remaining test skips (Couchbase).
…eyInterface)

The instanceof check used the non-existent PublicKey class instead of
PublicKeyInterface, causing all storage backends to skip. Also add
NullStorage guard to prevent errors from unavailable backends.
The couchbase extension has no pre-built binary in setup-php and
compiling from PECL hangs indefinitely. Remove the Couchbase container,
cluster setup, and extension from CI. Couchbase tests remain as skips.
DynamoDB rejects empty AttributeValue strings. The getEncryptionAlgorithm
method defaulted client_id to null, causing 'S' => null which is invalid.
Coalesce null to '0' (the sentinel key used for global keys) in all three
public key methods.
- Add .docker/Dockerfile based on php:*-cli-alpine with mongodb, redis,
  couchbase, pdo_mysql, pdo_pgsql, intl extensions pre-compiled
- Add docker.yml workflow to build and push images to GHCR for PHP
  8.1-8.4, triggered on Dockerfile changes and weekly schedule
- Update tests.yml to use container images for PHP 8.1-8.4 (with all
  services including Couchbase), PHP 8.5 remains on setup-php
- Make all service hostnames configurable via env vars in Bootstrap
  (MYSQL_HOST, POSTGRES_HOST, REDIS_HOST, MONGODB_HOST, CASSANDRA_HOST)
php:8.5-cli-alpine exists, so all 5 PHP versions now use the same
custom container image path. No more special-cased setup-php job.
Uses GitHub Actions cache backend (type=gha) with per-PHP-version
scopes so subsequent rebuilds only recompile changed layers.
The couchbase extension's classes weren't registering because apk del
removed shared libraries needed at runtime. Use scanelf to discover
all shared lib dependencies of compiled extensions and install them
before removing build deps.
The ext-couchbase 4.x C extension only provides low-level functions
(Couchbase\Extension\*) and exception classes. The high-level classes
(Cluster, ClusterOptions, Collection) come from the couchbase/couchbase
composer package.

- Install couchbase/couchbase:^4.4 in CI after composer install
- Update Bootstrap check to look for ClusterOptions class
- Add scanelf to Dockerfile to auto-detect runtime shared lib deps
- Keep couchbase/couchbase out of require-dev since it needs ext-couchbase
… bug

CouchbaseDB was the only storage missing unsetAccessToken. Also fix
AccessTokenTest calling getMessage() on non-NullStorage objects when
the method check fails.
Republish as our own package so we can ship the PHP 8.5 work without
waiting on bshaffer/oauth2-server-php (upstream PR bshaffer#1088 has been open
for a month with no response).

The "replace" block keeps this a drop-in for any consumer still
requiring bshaffer/oauth2-server-php.
The Docker CI image bakes a specific ext-couchbase build. Using ^4.4
in the on-the-fly composer require lets the resolver pull any newer
minor (e.g. 4.5.0), which expects native functions the older baked
extension doesn't export ("Call to undefined function
Couchbase\\Extension\\clusterLabels()"). Pin to the 4.4.x line so
the PHP wrapper and C extension stay compatible.
@maksimovic maksimovic changed the title chore: rename package to maksimovic/oauth2-server-php chore: modernize for PHP 8.1–8.5, republish as maksimovic/oauth2-server-php Apr 20, 2026
@maksimovic maksimovic changed the title chore: modernize for PHP 8.1–8.5, republish as maksimovic/oauth2-server-php Modernize for PHP 8.1–8.5, republish as maksimovic/oauth2-server-php Apr 20, 2026
@maksimovic maksimovic merged commit 2afa189 into main Apr 20, 2026
6 checks passed
@maksimovic maksimovic deleted the php85 branch April 20, 2026 14:50
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.

1 participant