Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Replace the fluent PHP config format by the array-shape one#21511

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Open
nicolas-grekas wants to merge2 commits intosymfony:8.0
base:8.0
Choose a base branch
Loading
fromnicolas-grekas:php-array

Conversation

@nicolas-grekas
Copy link
Member

@nicolas-grekasnicolas-grekas commentedOct 17, 2025
edited
Loading

Related tosymfony/symfony#62092symfony/symfony#62129 andhttps://symfony.com/blog/new-in-symfony-7-4-deprecated-xml-configuration

The diff itself isn't really interesting. What's interesting is comparing yaml to php arrays.

This can give a nice overview of the new format.

@carsonbotcarsonbot added this to the8.0 milestoneOct 17, 2025
@carsonbotcarsonbot changed the titleReplace the fluent PHP config format by the array-shape one Replace the fluent PHP config format by the array-shape oneOct 17, 2025
@nicolas-grekasnicolas-grekasforce-pushed thephp-array branch 4 times, most recently fromdc1e644 to730f41fCompareOctober 18, 2025 16:44
@nicolas-grekas
Copy link
MemberAuthor

nicolas-grekas commentedOct 18, 2025
edited
Loading

PR ready.
This took me quite some time to do manually, but with some LLM help, I shouldn't have made much mistakes.

@nicolas-grekasnicolas-grekasforce-pushed thephp-array branch 2 times, most recently from097460b to776698bCompareOctober 19, 2025 16:46
@javiereguiluz
Copy link
Member

Thanks for this! We should merge this soon to aovid merge conflicts with other PRs.

However, GitHub shows errors on these 5 files, so we should fix those:

  • logging/channels_handlers.rst
  • logging/monolog_console.rst
  • service_container/import.rst
  • configuration.rst
  • http_client.rst

@nicolas-grekas
Copy link
MemberAuthor

PR updated aftersymfony/symfony#62129

nicolas-grekas added a commit to symfony/symfony that referenced this pull requestOct 23, 2025
… to assist in writing and discovering app's configuration (nicolas-grekas)This PR was squashed before being merged into the 7.4 branch.Discussion----------[FrameworkBundle] Auto-generate `config/reference.php` to assist in writing and discovering app's configuration| Q             | A| ------------- | ---| Branch?       | 7.4| Bug fix?      | no| New feature?  | yes| Deprecations? | no| Doc PR |symfony/symfony-docs#21511| License       | MITThis PR reverts#61490 and#61885, and builds on#61894.These reverts explain a big chunk of the attached patch.This adds a compiler pass that generates a `config/reference.php` file.This file contains two classes that define array-shapes for app's and routing configuration.Part of these shapes are auto-generated from the list of bundles found in `config/bundles.php`.The `config/reference.php` file should be loaded by a new line in the "autoload" entry of composer.json files: `"classmap": ["config/"]` - recipe update pending. This means that the file should be committed. This is on purpose: as the name suggests, this file is also a config reference for human readers. Having to commit the changes is also a nice way to convey config improvements to the community - at least for ppl that review their commits ;). It also solves a discovery problem that happens with phpstan/etc having a hard time to find the classes currently generated for config builders in the cache directory.With this PR, `config/services.php` could start as such:```php<?phpnamespace Symfony\Component\DependencyInjection\Loader\Configurator;return App::config([    'services' => [        'App\\' => [            'resource' => '../src/'        ],    ],]);```and `config/routes.php` would start as:```php<?phpnamespace Symfony\Component\Routing\Loader\Configurator;return Routes::config([    'controllers' => [        'resource' => 'attributes',        'type' => 'tagged_services',    ]]);```The generated shapes use advanced features that are not fully supported by phpstan / phpstorm. But the gap should be closed soon.PS:https://symfony.com/blog/new-in-symfony-7-4-deprecated-xml-configuration will need an update.Commits-------22349f5 [FrameworkBundle] Auto-generate `config/reference.php` to assist in writing and discovering app's configuration
@nicolas-grekasnicolas-grekasforce-pushed thephp-array branch 2 times, most recently from2ae8fe4 toa042e8cCompareOctober 23, 2025 18:07
@nicolas-grekas
Copy link
MemberAuthor

nicolas-grekas commentedOct 23, 2025
edited
Loading

I replaced examples that usedconfig/package/env/ pattern towhen@env. This topic would deserves closer attention after merging. I think we can stop telling so much bout the subdir pattern.

wouterj reacted with thumbs up emoji

twig:
strict_variables:true
# config/packages/twig.yaml
when@test:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Nice update 👍🏻
Consistent with theTwig recipe.

Copy link
Member

@GromNaNGromNaN left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

I stopped at "security/".

'cache' => [
'pools' => [
'cache.mycache' => [
'adapter' => 'cache.adapter.redis',
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

This is a service id, but we could update the config to accept aReference:symfony/symfony#62142

Copy link
MemberAuthor

@nicolas-grekasnicolas-grekasOct 24, 2025
edited
Loading

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Not convinced we should diverge from what's possible in yaml.

'services' => [
AvatarPackage::class => [
'tags' => [
['assets.package' => ['package' => 'avatars']],
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Both syntaxes work. which one should be documented?

Suggested change
['assets.package' =>['package'=> 'avatars']],
['name' =>'assets.package', 'package'=> 'avatars'],

Copy link
MemberAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

I documented only the first in the shape for two reasons:

  • array{name: string, ...<string, mixed>} isn't supported so this would break the type
  • only the first allows attributes with keyname.

GromNaN reacted with thumbs up emoji
@nicolas-grekas
Copy link
MemberAuthor

Thanks@GromNaN, comments addressed.

@javiereguiluz
Copy link
Member

Just asking: the "code blocks" check is reporting many issues (https://github.com/symfony/symfony-docs/actions/runs/18777842138/job/53576516241?pr=21511) but I don't know if they are legit or just false positives because the review tooling is not ready to review this new format properly?

Copy link
Member

@GromNaNGromNaN left a comment
edited
Loading

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

I suspect that the security factory configurations are not loaded (testing on symfony/demo)

Comment on lines +40 to +54
return App::config([
'security' => [
'firewalls' => [
'main' => [
// allow authentication using a form or a custom authenticator
'form_login' => null,
'custom_authenticators' => [
SocialConnectAuthenticator::class,
],
// configure the form authentication as the entry point for unauthenticated users
'entry_point' => 'form_login',
],
],
],
]);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

The keysform_login andcustom_authenticators does not exist in the configuration. The issue is already in the Yaml.

Copy link
MemberAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

can you open an issue about this?

@nicolas-grekas
Copy link
MemberAuthor

Thanks@GromNaN, comments addressed (bis)

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

Reviewers

@wouterjwouterjwouterj left review comments

@xabbuhxabbuhAwaiting requested review from xabbuhxabbuh is a code owner

+1 more reviewer

@GromNaNGromNaNGromNaN left review comments

Reviewers whose approvals may not affect merge requirements

Assignees

No one assigned

Projects

None yet

Milestone

8.0

Development

Successfully merging this pull request may close these issues.

5 participants

@nicolas-grekas@javiereguiluz@GromNaN@wouterj@carsonbot

[8]ページ先頭

©2009-2025 Movatter.jp