Add Symfony 8 support - #64
Conversation
Widen Symfony version constraints in composer.json to allow ^8.0 across http-kernel, dependency-injection, expression-language, config, console, process, framework-bundle, finder, yaml and var-exporter. Symfony 8 removes XmlFileLoader support for DI service definitions. Convert all Resources/config/*.xml DI service files (and the test app's services.xml) to PHP ContainerConfigurator format, and switch TaskExtension and TestKernel from XmlFileLoader to PhpFileLoader. Doctrine ORM mapping XML files are untouched, as those use a separate XML driver unaffected by this removal. Bundle::build() gained a void return type in Symfony 8; add it to TaskBundle::build(). Doctrine ORM 3.4+ requires either PHP 8.4 native lazy objects or the legacy VarExporter-based lazy ghost proxies, the latter of which was removed from Symfony 8's ProxyHelper. Enable native lazy objects in the test app's doctrine config when running on PHP 8.4+, since Symfony 8 requires PHP 8.2+ and native lazy objects are the only supported option once VarExporter's generateLazyGhost() is gone on PHP 8.4. Fix a PHP 8.4 deprecation in DebugTasksCommand where round() could receive null when a task execution has no duration yet.
|
I have submitted this PR plus one on the |
The doctrine.orm.enable_native_lazy_objects config option was only added in doctrine/doctrine-bundle 2.15, which requires PHP >= 8.1. On the PHP 8.0 test job, Composer resolves an older doctrine-bundle that doesn't recognise this key, so the test app's Doctrine schema creation step failed with: Unrecognized option "enable_native_lazy_objects" under "doctrine.orm.entity_managers.default". Move the option into a separate config file that TestKernel only loads when the installed doctrine-bundle version actually supports it, detected via Composer\InstalledVersions. This keeps native lazy objects enabled on PHP 8.4+ with modern doctrine-bundle, without breaking older doctrine-bundle installs resolved on PHP 8.0/8.1.
aef0ad1 to
3d34280
Compare
| "symfony/framework-bundle": "^5.4 || ^6.0 || ^7.0 || ^8.0", | ||
| "symfony/finder": "^5.4 || ^6.0 || ^7.0 || ^8.0", | ||
| "symfony/yaml": "^5.4 || ^6.0 || ^7.0 || ^8.0", | ||
| "doctrine/doctrine-bundle": "^1.5 || ^2.0", |
There was a problem hiding this comment.
For Symfony 8 support Doctrine Bundle 3.0 is I think also a requirement.
wachterjohannes
left a comment
There was a problem hiding this comment.
LGTM except the thing with the doctrine bundle
| "symfony/framework-bundle": "^5.4 || ^6.0 || ^7.0 || ^8.0", | ||
| "symfony/finder": "^5.4 || ^6.0 || ^7.0 || ^8.0", | ||
| "symfony/yaml": "^5.4 || ^6.0 || ^7.0 || ^8.0", | ||
| "doctrine/doctrine-bundle": "^1.5 || ^2.0", |
|
@benr77 I updated the composer.json but seems like some return types need be also updated to make it compatible to Symfony 8. Do you want to tackle that? |
Symfony 8 hardens several DependencyInjection interfaces with strict return types. Add matching return types to TaskExtension and HandlerCompilerPass so their declarations stay compatible: - TaskExtension::getConfiguration(): ?ConfigurationInterface - TaskExtension::load(): void - TaskExtension::prepend(): void - HandlerCompilerPass::process(): void Without these, PHP raises a fatal 'Declaration ... must be compatible with ...' error on Symfony 8.
Symfony\Component\Console\Application::add() was removed in Symfony 8.0 in favour of addCommand(); use addCommand() when available and fall back to add() on older Symfony versions. doctrine/doctrine-bundle 3.0 removed the 'doctrine.orm.auto_generate_proxy_classes' config option, so only load it for older doctrine-bundle versions, the same way enable_native_lazy_objects is already guarded for newer ones. The test app registered DoctrineBundle unconditionally, even for the 'array' storage config which never loads any 'doctrine' extension config. On doctrine-bundle 3.x this made the container compilation fail with 'You have requested a non-existent parameter doctrine.dbal.connection_factory.types', since RegisterDbalTypePass now runs unconditionally for any registered DoctrineBundle. Only register DoctrineBundle when the 'doctrine' storage is selected.
There was a problem hiding this comment.
Pull request overview
This PR updates TaskBundle to be installable and runnable with Symfony 8 by widening Composer constraints and migrating DI service configuration away from XML (which Symfony 8 no longer supports for service definitions), while also updating the test application to handle DoctrineBundle/ORM behavior changes on newer PHP/Symfony versions.
Changes:
- Widen Symfony component constraints in
composer.jsonto allow^8.0(and expand Doctrine dev constraints accordingly). - Convert bundle + test-app DI service definitions from
Resources/config/*.xmlto PHPContainerConfiguratorfiles and switch loaders fromXmlFileLoadertoPhpFileLoader. - Update the test app kernel/config to conditionally load DoctrineBundle and handle DoctrineBundle/ORM options across versions; fix a PHP 8.4 deprecation in
DebugTasksCommand.
Reviewed changes
Copilot reviewed 35 out of 35 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/Functional/BaseCommandTestCase.php | Adds compatibility logic for registering commands across console application variants. |
| tests/app/TestKernel.php | Switches to PhpFileLoader, conditionally registers DoctrineBundle, and conditionally loads doctrine config based on installed bundle capabilities. |
| tests/app/config/services.xml | Removes XML-based test-app service definitions (replaced by PHP). |
| tests/app/config/services.php | Adds PHP ContainerConfigurator-based test-app service definitions. |
| tests/app/config/config.doctrine.yml | Removes auto_generate_proxy_classes from the base doctrine config (now version-gated). |
| tests/app/config/config.doctrine_native_lazy_objects.yml | Adds optional doctrine config enabling native lazy objects via a parameter. |
| tests/app/config/config.doctrine_auto_generate_proxy_classes.yml | Adds optional doctrine config for auto_generate_proxy_classes when supported. |
| src/TaskBundle.php | Adds : void return type to build() for Symfony 8 compatibility. |
| src/Resources/config/task_event_listener.xml | Removes XML parameters config (replaced by PHP). |
| src/Resources/config/task_event_listener.php | Adds PHP parameters config for task event constants. |
| src/Resources/config/storage/doctrine.xml | Removes XML doctrine storage service definitions (replaced by PHP). |
| src/Resources/config/storage/doctrine.php | Adds PHP doctrine storage service definitions. |
| src/Resources/config/storage/array.xml | Removes XML array storage service definitions (replaced by PHP). |
| src/Resources/config/storage/array.php | Adds PHP array storage service definitions. |
| src/Resources/config/scheduler.xml | Removes XML scheduler service definitions (replaced by PHP). |
| src/Resources/config/scheduler.php | Adds PHP scheduler service definitions. |
| src/Resources/config/locking/storages.xml | Removes XML locking storage definitions (replaced by PHP). |
| src/Resources/config/locking/storages.php | Adds PHP locking storage definitions (tagged storage services). |
| src/Resources/config/locking/services.xml | Removes XML locking services definitions (replaced by PHP). |
| src/Resources/config/locking/services.php | Adds PHP locking services definitions. |
| src/Resources/config/locking/null.xml | Removes XML null-lock definitions (replaced by PHP). |
| src/Resources/config/locking/null.php | Adds PHP null-lock definitions. |
| src/Resources/config/listener.xml | Removes XML listener service definitions (replaced by PHP). |
| src/Resources/config/listener.php | Adds PHP listener service definitions. |
| src/Resources/config/executor/separate.xml | Removes XML separate executor definitions (replaced by PHP). |
| src/Resources/config/executor/separate.php | Adds PHP separate executor definitions. |
| src/Resources/config/executor/inside.xml | Removes XML inside executor definitions (replaced by PHP). |
| src/Resources/config/executor/inside.php | Adds PHP inside executor definitions. |
| src/Resources/config/command.xml | Removes XML console command definitions (replaced by PHP). |
| src/Resources/config/command.php | Adds PHP console command definitions. |
| src/DependencyInjection/TaskExtension.php | Switches to PhpFileLoader and updates extension method signatures/config loading to use PHP DI resources. |
| src/DependencyInjection/HandlerCompilerPass.php | Adds : void return type to process() (and keeps handler-tag collection logic). |
| src/Command/DebugTasksCommand.php | Avoids passing null to round() by defaulting duration to 0.0. |
| composer.json | Expands Symfony and Doctrine constraints to include Symfony 8 + DoctrineBundle 3 / fixtures 2 where applicable. |
| .github/workflows/test-application.yaml | Extends CI matrix (adds PHP 8.5 entries; adjusts ignore-platform flags usage). |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
|
@benr77 Thank you, we tagged 4.1.0: https://github.com/php-task/TaskBundle/releases/tag/4.1.0 |
Widen Symfony version constraints in composer.json to allow ^8.0.
Symfony 8 removes XmlFileLoader support for DI service definitions. Convert all Resources/config/*.xml DI service files (and the test app's services.xml) to PHP ContainerConfigurator format, and switch TaskExtension and TestKernel from XmlFileLoader to PhpFileLoader.
Bundle::build() gained a void return type in Symfony 8; add it to TaskBundle::build().
Doctrine ORM 3.4+ requires either PHP 8.4 native lazy objects or the legacy VarExporter-based lazy ghost proxies, the latter of which was removed from Symfony 8's ProxyHelper. Enable native lazy objects in the test app's doctrine config when running on PHP 8.4+, since Symfony 8 requires PHP 8.2+ and native lazy objects are the only supported option once VarExporter's generateLazyGhost() is gone on PHP 8.4.
Fix a PHP 8.4 deprecation in DebugTasksCommand where round() could receive null when a task execution has no duration yet.