-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
Move internal Container configuration from XML to PHP #37186
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
Comments
I do something in Notifier Component few weeks ago. I think I can migrate src/Symfony/Bundle/FrameworkBundle/Resources/config/notifier.xml |
@szepczynski Great, can you do notifier_transports.xml as well? I've added you name on both :) |
yes, i missed them on the list |
One question about migrating FrameworkExtension - I guess that we need temporary two loaders, one for not migrated XMLs, and one for migrated until all configuration will be migrated. Can someone add at first Php Loader to FrameworkExtension that everyone who starting from current master don't need create Php Loader? |
I can start with |
@szepczynski Can you create the PHP loader in a separate PR that I can merge fast? |
@fabpot ok |
This PR was merged into the 5.2-dev branch. Discussion ---------- add php loader to FrameworkExtension | Q | A | ------------- | --- | Branch? | master <!-- see below --> | Bug fix? | no | New feature? | no <!-- please update src/**/CHANGELOG.md files --> | Deprecations? | no <!-- please update UPGRADE-*.md and src/**/CHANGELOG.md files --> | Tickets | #37186 <!-- prefix each issue number with "Fix #", if any --> | License | MIT Add php loader to migrate configuration from XML to PHP Commits ------- e05e811 add php loader to FrameworkExtension
For third-party bundles, I think it is too early to start this migration. The migration relies on using the new PHP DSL to configure services (migrating to the lower-level PHP API would not make sense as that would make maintenance harder). And this DSL is incomplete in previous versions of Symfony. |
I want to help. Can I try to migrate [serializer] or something else? |
Let me help. I can start from |
@mamontovdmitriy serializer is yours |
I want to give it a hand. Can I start with |
@phamuyentri Sure, can you do routing*.xml? |
Hi, |
@magnetik Thank you, it's yours now. |
Hi, I'd like to help with lock component. |
I can help with
|
@misekai Great! Thank you. |
@tomasjav Lock is yours, thank you |
This PR was merged into the 5.2-dev branch. Discussion ---------- [Notifier] Move configuration to PHP | Q | A | ------------- | --- | Branch? | master | Bug fix? | no | New feature? | no <!-- please update src/**/CHANGELOG.md files --> | Deprecations? | no <!-- please update UPGRADE-*.md and src/**/CHANGELOG.md files --> | Tickets | #37186 <!-- prefix each issue number with "Fix #", if any --> | License | MIT Move Notifier Component Container configuration to PHP Commits ------- 9891809 [Notifier] Move configuration yo PHP
I can help with |
@fabpot I can help with |
@dangkhoagms Thank you |
Hi @fabpot, I think I can help |
@fabpot I'd like to help with
|
@wouterj |
i just want to say that updating symfony is really hard job. |
I don't think you should have that feeling :). I think from a base, Symfony is just as flexible as in the past. However, I agree that one thing changed: The experience when using the default is now much much better by the introduction of Symfony Flex. This hasn't made the other formats worse though, they are still at the same level as when Symfony 2.0 was released. And to be honest, I think that makes sense. Symfony allows you to get to your destination. When using the paved road, you have a smooth experience to the destination. You can also use the unpaved road, you still get to the destination but the experience is not so smooth. In Symfony 2.0, there was no paved road, in Symfony 4.0+ there is a paved road. Anyway, yes it was a hard upgrade from the unpaved to the paved road in Symfony 4.0. I think the core team also realizes this. See e.g. this tweet from Fabien (responding to some people that expressed the same feelings as you): https://twitter.com/fabpot/status/1270981253962043392 "4.0 -> 5.2 is really about new features and refinements but no big changes. I don't envision any revolution in the next few versions either." In any case, this is completely off-topic for this issue, as this issue is purely internal. |
I feel you. I recommend you hire an external upgrade consultant to upgrade it. Doing it manually is hell... and non-sense in 2020. I do around 1 project upgrade a month on average, usually Symfony 3 to 5. With right tools like @rectorphp, coding standard and @phpstan it's piece of cake |
this month i did 6 upgrades. i have even developed my own tool for upgrading them. |
I just wanted to highlight:
I disagree, I used to bend Symfony in all most terrible ways I could think of (starting at 2.8) and it was fine, until 3.4. 3.4 did some great optimizations, and very nice end-user improvements, but it broke some of the natural flexibility it had before. I think it's the natural cost of specialisation and optimisation, nobody can't get around, not even Symfony. Don't take it wrong, it's not a complaint, I love Symfony and continue gladly to use it, yet in my experience, trying to walk out the paved road since 3.4 may be very difficult, at least compared to how it was very easy and nice before. Especially with debug component, which is really invasive, and a few other performance optimisations that made the code much harder to read, and broke some undocumented edge cases. |
FWIW (and sorry for the OT) I agree with the sentiment that the "paved road" comes with a cost. Increasing the magic while keeping the flexibility leads naturally to greater code complexity. This is also often the case for speed optimizations. The end result is a framework which makes a lot of tedious operations quick and easy, but is harder to grasp when you want to tweak/change bits of it. |
@fabpot Looks like this issue has caused some confusion and some people thought it affects all configuration files. Also see here: https://www.reddit.com/r/PHP/comments/h93fjc/symfony_will_now_promote_php_over_yaml_and_xml/. |
@fabian Can you be more specific? Which parts of configuration will stay in YAML? |
I think he's referring to semantic config (the one you parametrize through |
@Taluu As in bundles will still be configured in YAML? |
@enumag You can cofigure these in // src/Kernel.php
class Kernel extends BaseKernel
{
use MicroKernelTrait;
protected function prepareContainer(ContainerBuilder $container)
{
parent::prepareContainer($container);
(require dirname(__DIR__) . '/config/packages/workflow.php')($container);
}
} // config/packages/workflow.php
return static function (ContainerBuilder $container) {
$container->loadFromExtension(
'framework',
[
'workflows' => [
ChangeEmailWorkflow::NAME => [
"type" => "state_machine",
"marking_store" => [
"type" => "method",
"property" => "state",
],
"supports" => [Token::class],
"initial_marking" => ChangeEmailWorkflow::STATE_PENDING,
"places" => [
ChangeEmailWorkflow::STATE_PENDING,
ChangeEmailWorkflow::STATE_APPROVED,
ChangeEmailWorkflow::STATE_VERIFIED,
],
"transitions" => [
ChangeEmailWorkflow::TRANSITION_APPROVE => [
"from" => ChangeEmailWorkflow::STATE_PENDING,
"to" => ChangeEmailWorkflow::STATE_APPROVED,
],
ChangeEmailWorkflow::TRANSITION_VERIFY => [
"from" => ChangeEmailWorkflow::STATE_APPROVED,
"to" => ChangeEmailWorkflow::STATE_VERIFIED,
],
],
],
],
]
);
}; |
In Symfony 6, I we will promote usage of configuration written in PHP instead of YAML. For third-party bundles and core, we should do the same, replacing XML with PHP. Doing so would remove the need for the XML lib for core.
The biggest advantage is auto-completion with any modern IDE without explicit support for Symfony, and probably one less thing to learn (how to configure things in YAML/XML).
Be warned that semantic configuration will stay in YAML for now (as using PHP is much harder there).
#36778 did the work for the Twig bundle as an example.
We now need help from the community to move all the other bundles:
PLEASE, comment here BEFORE starting to work on something and WAIT for the confirmation to avoid duplicate work.
The text was updated successfully, but these errors were encountered: