-
Notifications
You must be signed in to change notification settings - Fork 202
allow Symfony 8, drop Symfony 5 #500
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
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR updates the KnpMenuBundle to support Symfony 8 by migrating from XML-based service configuration to PHP-based configuration and updating version constraints.
- Migrated all XML service configuration files to PHP format for better compatibility
- Updated Symfony dependency constraints to include version 8.0
- Updated CI configuration to test against Symfony 8
Reviewed Changes
Copilot reviewed 10 out of 10 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| src/DependencyInjection/KnpMenuExtension.php | Updated to use PhpFileLoader instead of XmlFileLoader and load .php config files |
| config/menu.php | New PHP service configuration replacing menu.xml |
| config/twig.php | New PHP service configuration replacing twig.xml |
| config/templating.php | New PHP service configuration replacing templating.xml |
| composer.json | Updated Symfony version constraints to support 8.0 and updated test dependencies |
| .php-cs-fixer.php | Added exclusions for 'param' and 'service' functions in native function invocation |
| .github/workflows/build.yaml | Updated CI matrix to test Symfony 8 and removed 5.4 testing |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
|
Sigh. Somehow I missed this, and have done some of the same work in my branch. Glad it's done, and hope this PR get merged now that Symfony 8 beta 1 is out. |
I'm interested in a possible comparison. Did you end up with the same changes? Does it work for you? |
|
The biggest change was the XML to PHP configuration. Fortunately, AI does a good job with that. I got stuck with getting tests to pass cs-fixer:
https://github.com/tacman/KnpMenuBundle/actions/runs/18857731525/job/53809488034 |
You need a change in the "native_function_invocation" configuration |
|
Maybe a good time to learn how to properly use cs-fixer! <?php
// see https://github.com/FriendsOfPHP/PHP-CS-Fixer
$finder = PhpCsFixer\Finder::create()
->exclude('vendor')
->in([__DIR__])
;
return (new PhpCsFixer\Config())
->setRiskyAllowed(true)
->setRules([
'@Symfony' => true,
'@Symfony:risky' => true,
'@PHP71Migration:risky' => true,
'@PHPUnit75Migration:risky' => true,
'ordered_imports' => true,
'declare_strict_types' => false,
'native_function_invocation' => ['include' => ['@all']],
])
->setFinder($finder)
;What should it be in order for tests to pass? |
It's in the diff of this very PR |
|
FYI, a migration tool for the migration of XML config to PHP configs has been implemented in https://github.com/GromNaN/symfony-config-xml-to-php |
.php-cs-fixer.php
Outdated
| 'ordered_imports' => true, | ||
| 'declare_strict_types' => false, | ||
| 'native_function_invocation' => ['include' => ['@all']], | ||
| 'native_function_invocation' => ['include' => ['@all'], 'exclude' => ['param', 'service']], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A better fix might be to trigger the autoloading of the PhpFileLoader class, so that the function definitions are loaded, and so PHP-CS-Fixer would know that they are not global.
.github/workflows/build.yaml
Outdated
| dev: true | ||
| - description: 'Dev deps' | ||
| php: '8.4' | ||
| symfony: ^8.0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this should be reverted. The dev deps job should be running with unmodified requirements.
|
this PR does not just allow Symfony 8. It also drop supports for Symfony 5.4 without even mentioning it. |
We can all agree that maintaining three versions of Symfony at the same time is enough. Four is too much. |
|
@garak I'm not saying we should not drop that. But we must communicate it instead of hiding it in a PR saying it only adds support for Symfony 8 (otherwise, it might end up being missing from the changelog as well) |
composer.json
Outdated
| "symfony/dependency-injection": "^6.0 | ^7.0 | ^8.0", | ||
| "symfony/deprecation-contracts": "^2.5 | ^3.3", | ||
| "symfony/http-kernel": "^5.4 | ^6.0 | ^7.0" | ||
| "symfony/http-kernel": "^6.0 | ^7.0 | ^8.0" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we drop support for Symfony 5.4, I would bump the min version to 6.4 (i.e. the 6.x LTS version) instead of 6.0
We removed the changelog more than one year ago. Changes are registered in the releases page. I see your concern anyway, I'll change the PR title |
70fa392 to
f4b2731
Compare
|
@garak removing the changelog.md file inside the repo does not mean we removed the changelog at all. We just changed the location of the changelog (now, the changelog is only in the description of github releases) |
|
Is it an option to split it in 2 PRs? One to migrate config XML => php |
|
Shouldn't it be ^6.4|^7.3|^8.0? the older versions aren't supported anymore. |
|
|
|
In term of maintenance for us, supporting 6.4 as our lowest bound makes us compatible with 7.0 at no maintenance cost (as 7.0 contains all the non-deprecated features of 6.4). |
|
So maybe I'm not understanding how Symfony maintains older versions. Let's say PHP 8.5 has removes something in Symfony 7.*. Would ALL the version of Symfony 7 get fixed, include 7.0? My understanding was that it would not, only the maintained versions would get the fix. Or if Symfony 7.4 changes a signature, won't all the previously maintained versions get the fix as well, but not the unmaintained ones? https://symfony.com/releases/7.0 I understand that if the bundle does actually support Symfony 7.0 there's no reason to require a higher version. I guess I'm thinking back to all the bundles that didn't extend AbstractBundle because they wanted to support 6.0 even after it became unmaintained. |
|
The issue is not about whether 7.0.x still receives bug fixes. As long as we don't rely on a specific fix, there is no reason for us to be very strict (this bundle won't be a sufficient reason for projects to upgrade Symfony if they are using an unmaintained Symfony version). |
|
Any chance this could be merged? 🙏 Its currently blocking me from adding Symfony 8 support on sonata-project/SonataBlockBundle#1245 |

Fix #499