Skip to content

PHP 8.4 / Symfony 7.4 LTS Upgrade + front-end tests - #995

Open
ketura wants to merge 6 commits into
ThronesDB:masterfrom
PlayersCouncil:symfony-upgrade
Open

ketura wants to merge 6 commits into
ThronesDB:masterfrom
PlayersCouncil:symfony-upgrade

Conversation

@ketura

@ketura ketura commented Nov 1, 2026

Copy link
Copy Markdown

Giving that I am forking this for the game community I manage (the LOTR-TCG), I found it prudent to give back with the initial upgrades I found necessary, namely bringing ThronesDB to a version of PHP and Symfony that are current, which is all the more necessary in this day and age of AI-riddled critical bugs.

Before the upgrade, I added a full Docker setup for hosting the entire application (not just for development in VSCode, which I see you have in the .devcontainer) and then set up some Playwright (GUI) tests that could be ran before and after the upgrade to ensure that basic functionality was still in place. Those tests covered registration, logging in, creating a deck, voting on and commenting on decks, importing decks, and several other structural features at a basic level. These could of course be expanded upon for future work.

Post-upgrade, there were a number of libraries which are now abandoned, out of service, or deprecated, which were replaced by the most standard equivalent I could identify. In particular travis.ci is no longer a thing for open source projects; it is replaced here with a script that covers similar testing, but it could be converted to a GitHub Action as well, which is not something I could just push over to this repo (the info for that is at the end if you'd prefer that, however).

These changes were executed at my direction by Claude Opus 5.5, who also drafted the below details. I stand by this upgrade as it is now at the heart of the fork that I will be running, and figure it might be useful to anyone following.

Summary

This PR brings ThronesDB onto supported versions and adds the tooling to run and check it:

  1. Docker setup. One image and a compose file run the whole site, with first-time setup and a dev overlay.
  2. Playwright browser tests. They cover the main flows end to end, plus screenshot comparison between versions.
  3. Upgrade to Symfony 7.4 LTS on PHP 8.4, straight from Symfony 4.4 / PHP 7.4. Bundles that are dead or can't run on Symfony 7 are replaced.

The commits are in that order and each one builds and runs. The Docker setup and the test suite were committed and run on PHP 7.4 first, so the upgrade could be checked against the same tests and screenshots.

Why: end-of-life status

Component Before Status After
PHP 7.4 Security support ended 28 Nov 2022 8.4 (security support to 31 Dec 2028)
Symfony 4.4 LTS Security support ended 21 Nov 2023 7.4 LTS (bug fixes to Nov 2028, security to Nov 2029)
SwiftMailer 6.x Maintenance ended Nov 2021; replaced by symfony/mailer symfony/mailer
sensio/framework-extra-bundle 5.x Abandoned on Packagist; replaced by Symfony's native attributes removed
doctrine/annotations 1.x Deprecated in favour of PHP attributes removed
FOSOAuthServerBundle 1.6 Last release 2018 (2.0.0-alpha), requires Symfony 3/4 league/oauth2-server-bundle 1.2
JMSI18nRoutingBundle 3.x Last release Feb 2021 Symfony's localized routes
FOSUserBundle 2.2 Superseded 4.1
MySQL (in .env example) 5.7 Extended support ended 31 Oct 2023 8.4 LTS in Docker (support to 2032)
CI Travis (travis-ci.org) travis-ci.org shut down in 2021; the config targeted PHP 7.4 Removed; checks run through docker/check.sh (see below)

I went straight to 7.4 instead of 6.4 because 6.4 stops getting bug fixes on 30 Nov 2026. Stepping through 5.4 and 6.4 would also have meant migrating several bundles more than once, since their APIs changed at each major version.

What's in it

Docker (docker/)

  • One image, two roles. A single php:<ver>-apache image runs either the web app or a one-shot init. The web app container also runs the scheduled jobs (supercronic, docker/crontab) alongside Apache. If either process exits, the container exits and Docker restarts it.
  • Compose. docker-compose.yml runs the app plus MySQL 8.4. Both are published on 127.0.0.1 only, with state bind-mounted under docker/data/ and capped logs and memory limits.
  • init. It runs migrations, loads default data, clones and imports the card data and restricted lists, and optionally creates an admin account. It refuses to wipe a database that already has cards unless INIT_FORCE=1.
  • Dev overlay (docker-compose.dev.yml). Source and templates are bind-mounted from the checkout, and Mailpit catches mail.
  • Reverse proxy. TRUSTED_PROXIES is set so a proxy on the host can terminate TLS.
  • Docs. docker/README.md covers setup, updates, console commands and proxying.

Browser tests (tests/e2e/)

  • Accounts: registration with the confirmation email, login, logout, wrong password and password reset. Mail is read from Mailpit.
  • Decks: deckbuilder, import from text, delete.
  • Decklists: publish one, then another user likes, favourites and comments on it. Decklist search, the favourites list, and the public card and decklist API.
  • OAuth2: the full flow (client registration, consent, code exchange, refresh, protected API, deny).
  • Other pages: public pages, and the Spanish site on es.<host>.
  • Failure rules: any JavaScript error or server error on a page fails the test. Each run registers its own accounts, so it doesn't depend on existing data.
  • Records: every run saves step screenshots and a trace. A separate visual project compares key pages between two versions.
  • Overlay: docker-compose.e2e.yml runs the stack for the tests.

Upgrade

  • Symfony and Doctrine: symfony/* 4.4 → 7.4 with symfony/runtime and the standard 7.x kernel, front controller and console. Doctrine ORM 2.6 → 2.20 and DBAL 2 → 3.
  • Bundles: FOSUserBundle 4.1, NelmioApiDocBundle 5 (OpenAPI 3), FOSJsRoutingBundle 3, BazingaJsTranslationBundle 8 and Monolog 3.
  • Attributes: routes, Doctrine mapping, Gedmo and validation constraints are now PHP attributes, converted with Rector (rector.php included).
  • Mail: SwiftMailer → symfony/mailer.
  • OAuth2: FOSOAuthServerBundle → league/oauth2-server-bundle.
    • Scopes and the ROLE_READ_DECK / ROLE_WRITE_DECK roles stay the same.
    • Endpoints are /oauth/v2/authorize, the old /oauth/v2/auth, and /oauth/v2/token.
    • A new consent page asks the user before a client is authorized.
  • Routing: JMSI18nRoutingBundle → Symfony's localized routes, keeping the hostname-per-language setup (English on APP_WEBSITE_URL, Spanish on es.<host>). The JSON APIs answer on any hostname.
  • PHP and template deprecations:
    • PHP 8.1–8.4: Serializable, implicit nullable parameters, "${var}" interpolation.
    • Deprecated DBAL fetch methods replaced.
    • transchoice → trans with %count%.
  • Tests and tooling: PHPUnit 11 (attributes, static data providers; the api group stays excluded by default, as before) and PHPStan 2.
  • Checks: docker/check.sh (or make check) runs PHPUnit, lint (YAML, Twig, container, Doctrine mapping), PHPStan, PHP_CodeSniffer and the production image build, all inside the Dockerfile's new test stage. They run the same way on any machine with Docker, and from any CI that can run a shell script.
  • Travis removed: .travis.yml, .env.travis and the README badge are deleted. travis-ci.org shut down in 2021, so the config hasn't run since. It also targets PHP 7.4, which this code no longer runs on, so keeping it would document a setup that no longer exists.
  • Dev container: updated to PHP 8.4 / Node 22. README and Makefile updated.

Bugs fixed

The upgrade turned up three existing bugs:

  • Review-comment notification emails never sent. ReviewController called $$mailer (variable variable) instead of $mailer.
  • The "remind" confirmation email failed. It called a FOSUserBundle mailer method on the SwiftMailer service.
  • An OAuth API test checked the wrong response shape. The response is wrapped in {data: [...]}, and the test didn't account for that.

Upgrade notes for deployers

  • PHP 8.4 is required.
  • Mail: MAILER_URL is replaced by MAILER_DSN (e.g. smtp://user:pass@host:587).
  • OAuth2 signing keys: a key pair is needed (OAUTH_PRIVATE_KEY / OAUTH_PUBLIC_KEY; the openssl commands are in .env). The Docker setup creates one on first start.
  • Existing OAuth2 clients must be registered again with league:oauth2-server-client:create-client. The new bundle's client IDs are at most 32 characters and the old <id>_<random> IDs don't fit. The migration renames the old tables to legacy_fos_oauth_* instead of dropping them. Existing tokens stop working.
  • Passwords: existing salted SHA-512 hashes keep working. New and changed passwords use the current default algorithm.
  • Dev URLs: dev now uses the same hostname scheme as production (es.localhost instead of /es/ prefixes).

Testing

  • docker/check.sh passes: PHPUnit (plus the api group run separately), PHPStan, PHP_CodeSniffer and all lints.
  • The Playwright suite passes on both the PHP 7.4 baseline and the upgrade.
  • Screenshots of key pages match the 7.4 baselines.
  • A fresh install with init works on the 8.4 image.

If you want CI

This PR doesn't add a CI workflow. If you'd like one, this GitHub Actions file runs the same checks:

# .github/workflows/ci.yml
name: CI
on: [push, pull_request]
jobs:
  checks:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v5
      - run: docker/check.sh

Known follow-ups

Two things are deprecated but still work on 7.4:

  • Request::get() calls, which are removed in Symfony 8.
  • Doctrine ORM 2 lazy-ghost proxies; ORM 3 uses native lazy objects.

ketura and others added 6 commits October 31, 2026 18:54
One image (php:7.4-apache, Composer and gulp builds baked in) runs three
roles chosen by command: the web app, scheduled jobs (supercronic) and a
one-shot first-time setup. docker/docker-compose.yml runs them with MySQL
8.4; state is bind-mounted under docker/data/.

- docker/Dockerfile: multi-stage build; falls back to archive.debian.org
  now that Debian 11 packages are leaving the main mirrors
- docker/entrypoint.sh: waits for the database, writes msmtp's config from
  SMTP_* variables (SwiftMailer already sends through msmtp), warms the
  cache; migrations only when RUN_MIGRATIONS=1
- docker/init.sh: migrations, default data, card data clone and import,
  restricted lists, optional admin account; refuses to wipe a database that
  already has cards unless INIT_FORCE=1
- docker/docker-compose.dev.yml: dev environment, PHP/Twig bind-mounted from
  the checkout, Mailpit for mail
- php.ini sets variables_order=EGPCS so container env vars reach Symfony
  under mod_php
- TRUSTED_PROXIES set for a reverse proxy on the host
- docker/README.md documents setup, updates, console commands and proxying

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01QWHJ1Ekh1MTES8JcxhiAzr
Drop the separate cron container: the app container's entrypoint now runs
supercronic alongside Apache. If either process exits, the entrypoint stops
the other and exits, so Docker restarts the container instead of leaving it
serving pages without its jobs (or the reverse). docker stop still sends
SIGWINCH, which is passed to Apache as a graceful stop.

Also give the database a minute to shut down before Docker kills it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01QWHJ1Ekh1MTES8JcxhiAzr
tests/e2e drives the site in a real browser against the Docker stack,
covering the main flows end to end:

- registration with the confirmation email, login, logout, wrong password,
  password reset email (mail read from Mailpit)
- building a deck in the deckbuilder, importing one from text, deleting
- publishing a decklist; another user likes, favourites and comments
- decklist search, the favourites list, public card and decklist API
- public pages, and the Spanish site on the es. subdomain

Every test fails on any JavaScript error or server error on the page.
Each run registers its own two accounts, so runs don't depend on existing
data. A separate project compares screenshots of key pages between two
versions (baselines recorded locally, not committed).

docker/docker-compose.e2e.yml runs the stack for the tests: production
environment, served as localhost, all mail caught by Mailpit. Mailpit is
pinned to v1.33.0 in both overlays.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01QWHJ1Ekh1MTES8JcxhiAzr
Passing runs previously left nothing behind (screenshots and traces were
kept only on failure). Now every test records a final full-page screenshot
and a trace, and the specs attach named screenshots at key steps via
snap(). Each run's HTML report goes in its own folder under reports/,
named by local start time; npm run report opens the newest,
npm run reports:clean keeps the newest 10.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01QWHJ1Ekh1MTES8JcxhiAzr
Symfony 4.4 and PHP 7.4 have been out of support since 2023 and 2022.
This moves straight to the current LTS (7.4: bug fixes to Nov 2028,
security fixes to Nov 2029) rather than stepping through 5.4 and 6.4.

Dependencies
- symfony/* 4.4 -> 7.4, with symfony/runtime and the standard 7.x kernel,
  front controller and console
- Doctrine ORM 2.6 -> 2.20, DBAL 2 -> 3, DoctrineBundle 2.19, mapping by
  attributes
- FOSUserBundle 2.2 -> 4.1; nelmio/api-doc-bundle 3 -> 5 (OpenAPI 3);
  FOSJsRoutingBundle 3, BazingaJsTranslationBundle 8, Monolog 3,
  PHPUnit 11, PHPStan 2

Replaced
- SwiftMailer -> symfony/mailer (MAILER_DSN). Also fixes two mail bugs:
  review-comment notifications ($$mailer) and the "remind" confirmation
  email (called a FOSUser method on the SwiftMailer service)
- FOSOAuthServerBundle -> league/oauth2-server-bundle. Same scopes and
  ROLE_READ_DECK / ROLE_WRITE_DECK roles; endpoints /oauth/v2/authorize
  (and the old /oauth/v2/auth) and /oauth/v2/token; a consent page asks
  the user before a client is authorized. Needs an RSA key pair
  (OAUTH_PRIVATE_KEY / OAUTH_PUBLIC_KEY). Existing OAuth2 clients must be
  registered again (league:oauth2-server:create-client): the migration
  keeps the old tables as legacy_fos_oauth_* but their client IDs don't
  fit the new format, and old tokens stop working
- JMSI18nRoutingBundle -> Symfony's localized routes, with the same
  hostname-per-language setup (en on APP_WEBSITE_URL, es on es.<host>);
  the JSON APIs answer on any hostname
- sensio/framework-extra-bundle, doctrine/annotations: removed; routes,
  Doctrine mapping, Gedmo and validation constraints are PHP attributes
  (converted with Rector, rector.php)

Passwords: existing salted SHA-512 hashes keep working; new and changed
passwords use the current default algorithm.

Also: transchoice tags -> trans with %count%; deprecated DBAL fetch
methods; PHP 8.1-8.4 deprecations (Serializable, implicit nullable
parameters, "${var}" interpolation); PHPUnit tests on attributes and
static data providers ("api" group excluded by default, as in the old CI).

Known follow-ups, deprecated but working on 7.4: Request::get() calls
(removed in Symfony 8), Doctrine lazy ghost proxies (ORM 3 uses native
lazy objects).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01QWHJ1Ekh1MTES8JcxhiAzr
- Docker image on php:8.4-apache; mail through MAILER_DSN instead of msmtp;
  OAuth2 key pair created on first start in docker/data/oauth; new "test"
  build stage with dev dependencies for PHPUnit
- docker/check.sh (also "make check") runs PHPUnit, the lints (YAML, Twig,
  container, Doctrine mapping), PHPStan, PHP_CodeSniffer and the production
  image build, all through the test image, so the same checks run on any
  machine with Docker and from any CI that can run a shell script
- Travis config removed: travis-ci.org shut down in 2021 and the config
  targeted PHP 7.4, which the code no longer runs on; README badge removed
- Playwright: OAuth2 flow test (client registration, consent, code
  exchange, refresh, protected API, deny)
- Dev container on PHP 8.4 / Node 22; README and Makefile updated

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01QWHJ1Ekh1MTES8JcxhiAzr
@stopfstedt stopfstedt self-assigned this Nov 4, 2026
@stopfstedt
stopfstedt self-requested a review November 4, 2026 03:48
@stopfstedt

Copy link
Copy Markdown
Collaborator

hey @ketura - thanks for the PR. this is coming in very timely - i've been finally working on a Symfony upgrade again, so Ii definitely want those changes. Not sure about the rest just yet (more Docker, playwright tests).

i'll give it a close look in the next week or two, and take from here what's needed.

in any case - much appreciated.

@ketura

ketura commented Nov 4, 2026

Copy link
Copy Markdown
Author

No problem at all! And yeah if you end up just cannibalizing the PR for another, that's fine too; just wanted to make sure I was giving back.

Cheers!

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.

2 participants