Skip to content

Conversation

@garak
Copy link
Collaborator

@garak garak commented Oct 11, 2025

Fix #499

@garak garak added the hacktoberfest-accepted https://hacktoberfest.digitalocean.com label Oct 11, 2025
@garak garak requested review from Copilot and stof October 11, 2025 14:27
Copy link

Copilot AI left a 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.

@tacman
Copy link
Contributor

tacman commented Oct 27, 2025

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.

@garak
Copy link
Collaborator Author

garak commented Oct 28, 2025

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?

@tacman
Copy link
Contributor

tacman commented Oct 28, 2025

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:

image

https://github.com/tacman/KnpMenuBundle/actions/runs/18857731525/job/53809488034

@garak
Copy link
Collaborator Author

garak commented Oct 28, 2025

I got stuck with getting tests to pass cs-fixer:

You need a change in the "native_function_invocation" configuration

@tacman
Copy link
Contributor

tacman commented Oct 28, 2025

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?

@garak
Copy link
Collaborator Author

garak commented Oct 28, 2025

What should it be in order for tests to pass?

It's in the diff of this very PR

@stof
Copy link
Collaborator

stof commented Oct 28, 2025

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

'ordered_imports' => true,
'declare_strict_types' => false,
'native_function_invocation' => ['include' => ['@all']],
'native_function_invocation' => ['include' => ['@all'], 'exclude' => ['param', 'service']],
Copy link
Collaborator

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.

dev: true
- description: 'Dev deps'
php: '8.4'
symfony: ^8.0
Copy link
Collaborator

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.

@stof
Copy link
Collaborator

stof commented Oct 28, 2025

this PR does not just allow Symfony 8. It also drop supports for Symfony 5.4 without even mentioning it.

@garak
Copy link
Collaborator Author

garak commented Oct 28, 2025

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.

@stof
Copy link
Collaborator

stof commented Oct 28, 2025

@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"
Copy link
Collaborator

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

@garak
Copy link
Collaborator Author

garak commented Oct 28, 2025

@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)

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

@garak garak changed the title allow Symfony 8 allow Symfony 8, drop Symfony 5 Oct 28, 2025
@garak garak force-pushed the php-config branch 2 times, most recently from 70fa392 to f4b2731 Compare October 28, 2025 15:35
@stof
Copy link
Collaborator

stof commented Oct 28, 2025

@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)

@Chris53897
Copy link
Contributor

Chris53897 commented Nov 6, 2025

Is it an option to split it in 2 PRs?

One to migrate config XML => php
And another for dropping support for symfony 5.4 (under discussion ?), and adding support for symfony 8

@tacman
Copy link
Contributor

tacman commented Nov 6, 2025

Shouldn't it be ^6.4|^7.3|^8.0? the older versions aren't supported anymore.

@Chris53897
Copy link
Contributor

^6.4|^7.0|^8.0 will make migration for users easier

@stof
Copy link
Collaborator

stof commented Nov 6, 2025

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).
and this range will allow projects to use the latest version of the bundle even if they are late on the Symfony 7.x updates, which is better for us than forcing them to use an older version of the bundle that they might ask us to maintain.

@tacman
Copy link
Contributor

tacman commented Nov 6, 2025

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.

@stof
Copy link
Collaborator

stof commented Nov 6, 2025

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).

@dmaicher
Copy link

Any chance this could be merged? 🙏 Its currently blocking me from adding Symfony 8 support on sonata-project/SonataBlockBundle#1245

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

hacktoberfest-accepted https://hacktoberfest.digitalocean.com

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support Symfony 8

6 participants