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

[DependencyInjection] [POC] Introduce build parameters#47608

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

Closed

Conversation

@HeahDude
Copy link
Contributor

@HeahDudeHeahDude commentedSep 17, 2022
edited
Loading

QA
Branch?6.2
Bug fix?no
New feature?yes
Deprecations?no
Tickets~
LicenseMIT
Doc PRTODO

We miss a way to optimise dumped container with compile-time only parameters, or ability to remove them in a straightforward/easy to discover way:

// before$containerBuilder->getParameterBag()->remove(...);// after$containerBuilder->removeParameter(...);
$containerBuilder->setBuildParameter(...);// will be removed before dumping// with configurator$container->parameters()    ->set('param','X')    ->set('build_param','Y', buildOnly:true)
# services.yamlbuild_parameters:...parameters:...
<!-- services.xml--><container ...>    <build-parameters>        <parameter ...>...</parameter>    </build-parameters>    <parameters>        <parameter ...>...</parameter>    </parameters></container>

chalasr and Guikingone reacted with thumbs up emoji
@carsonbotcarsonbot added this to the6.2 milestoneSep 17, 2022
@carsonbotcarsonbot changed the title[POC][DependencyInjection] Introduce build parameters[DependencyInjection] [POC] Introduce build parametersSep 17, 2022
Copy link
Member

@nicolas-grekasnicolas-grekas left a comment

Choose a reason for hiding this comment

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

I didn't finish my review but I'm wondering: instead of adding new methods, wouldn't it be better and simpler to have a naming convention for build-time parameters? My proposal would be to consider that any parameter who's name starts with a dot will removed from the compiled container.

parameters:.abc:def

chalasr and OskarStark reacted with thumbs up emoji
*
* @var array<string, false>
*/
publicarray$buildParameters = [];

Choose a reason for hiding this comment

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

better have a getter, no need to make it internal


publicfunctionremoveParameter(string$parameter):void
{
$this->parameterBag->remove($parameter);

Choose a reason for hiding this comment

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

no need for the removeParamter method I suppose

Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

You're right, for DX purpose this could be a dedicated PR if needed.

$c .=''.$this->doExport($id)." => true,\n";
}
$files['removed-ids.php'] =$c."];\n";
$files['removed-service-ids.php'] =$c."];\n";

Choose a reason for hiding this comment

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

i'd keet the current name and name the new oneremoved-parameters.php

HeahDude reacted with thumbs up emoji
@HeahDude
Copy link
ContributorAuthor

HeahDude commentedSep 18, 2022
edited
Loading

My proposal would be to consider that any parameter who's name starts with a dot will removed from the compiled container.

I considered it, but I'm worried about potential BC breaks this could cause.

@chalasr
Copy link
Member

I considered it, but I'm worried about potential BC breaks this could cause

Might be worth adding some global config option or DI parameter as we did for the autowiring' strict mode?
I like the suggested convention a lot.

HeahDude reacted with thumbs up emoji

@wouterj
Copy link
Member

I'm not sure if I prefer convention over an explicit option. And needing an explicit option to turn on a convention in order to use this feature seems even less than ideal to me :)

@nicolas-grekas
Copy link
Member

The BC break seems theoretical to me. I think that's still my preferred solution and how I'd like this topic be solved.

OskarStark reacted with thumbs up emoji

@HeahDude
Copy link
ContributorAuthor

See#47680 for the suggested implementation.

@chalasr
Copy link
Member

Thanks. Closing in favor of#47680

@HeahDudeHeahDude deleted the feat/di-build-parameters branchSeptember 25, 2022 13:58
chalasr added a commit that referenced this pull requestDec 5, 2022
…meters (HeahDude)This PR was squashed before being merged into the 6.3 branch.Discussion----------[DependencyInjection][HttpKernel] Introduce build parameters| Q             | A| ------------- | ---| Branch?       | 6.3| Bug fix?      | no| New feature?  | yes| Deprecations? | yes| Tickets       | ~| License       | MIT| Doc PR        | TODOAlternative implementation of#47608.Add a convention for parameters named with a starting dot to be available at compile-time only:```php$containerBuilder->setParameter('foo'); // nothing changes$containerBuilder->setParameter('.bar'); // will not be dumped```Calling `$container->getParameter('.bar')` on a compiled container will throw.Commits-------c75dbca [DependencyInjection][HttpKernel] Introduce build parameters
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@nicolas-grekasnicolas-grekasnicolas-grekas left review comments

Assignees

No one assigned

Projects

None yet

Milestone

6.2

Development

Successfully merging this pull request may close these issues.

5 participants

@HeahDude@chalasr@wouterj@nicolas-grekas@carsonbot

[8]ページ先頭

©2009-2025 Movatter.jp