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

Updates to DI config for 3.3#7807

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

Merged
weaverryan merged 23 commits intomasterfromdi-3.3-changes
May 5, 2017
Merged

Updates to DI config for 3.3#7807

weaverryan merged 23 commits intomasterfromdi-3.3-changes
May 5, 2017

Conversation

@weaverryan
Copy link
Member

@weaverryanweaverryan commentedApr 15, 2017
edited
Loading

Hi guys!

WIP changes the new DI changes in 3.3! Woohoo! Some notes for myself:

This relates to, oh, just these 10+ issues :). Assume they will all be closed by this one PR - before merge, if any of them aren't covered, I'll remove them.

TODOS later (some might already be done)

  • update to usedebug:container --types (debug:container --types (classes/interfaces) symfony#22624)
  • update all other documents for possible changes for autowiring and autoconfigure
  • new page for existing Symfony users to explain the changes
  • update autowire section to talk about using aliases
  • document instanceof and also the ability to add configuration to the PSR4 loader
  • some links in the controller go to the API docs ofController. But this is wrong, the methods
    now live inControllerTrait... but the API docs for traits is basically broken:http://api.symfony.com/master/Symfony/Bundle/FrameworkBundle/Controller/ControllerTrait.html
  • how should we pass a parameter to a controller?
  • do Twig extensions still need to be public? If so, the example inservice_container about autoconfigure is still not quite right

Definitely included in this PR

Not included in this PR (but related to DI changes)

# configures defaults for all services in this file
_defaults:
autowire:true
autoconfigure:true
Copy link
MemberAuthor

Choose a reason for hiding this comment

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

this isn't merged yet -symfony/symfony#22234 - but has all the 👍 so I expect it will

Choose a reason for hiding this comment

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

I'd encourage addingpublic: false also

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.

some suggestions

# configures defaults for all services in this file
_defaults:
autowire:true
autoconfigure:true

Choose a reason for hiding this comment

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

I'd encourage addingpublic: false also

}

That's it! The container will *automatically* know to pass the ``logger`` service
when instantiating the ``MessageGenerator``? How does it know to do this? The key

Choose a reason for hiding this comment

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

first? should be a dot

# registers all classes in the dir(s) as services
AppBundle\:
resource:'../../src/AppBundle/{Service}'

Choose a reason for hiding this comment

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

If we only display 1 dir, is confusing to use the glob syntax.

nicolas-grekas, xabbuh, and apfelbox reacted with thumbs up emoji
array()
));
That's it! Thanks to the ``AppBundle\`` line and ``resource`` key below it, all
classes in the ``src/AppBundle/Service`` directory will automatically be added to
Copy link
Member

@javiereguiluzjaviereguiluzApr 16, 2017
edited
Loading

Choose a reason for hiding this comment

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

This phrase looks strange:

[...] all classes in the Service dir will be added to the container

Shouldn't it be like this?

[...] a service will be registered in the container for every class in the Service dir.

is the ``LoggerInterface`` type-hint in your ``__construct()`` method and the
``autowire: true`` config in ``services.yml``. When you type-hint an argument, the
container will automatically find the matching service. If it can't or there is any
ambuiguity, you'll see a clear exception suggesting how to fix it.

Choose a reason for hiding this comment

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

ambuiguity ->ambiguity

# explicitly configure the service
AppBundle\Updates\SiteUpdateManager:
arguments:
$adminEmail:'manager@example.com'

Choose a reason for hiding this comment

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

I still think that the$ in the argument name is really strange inside a YAML file ... but I was already told that this "can't" be improved :(

That's it! Thanks to the ``AppBundle\`` line and ``resource`` key below it, all
classes in the ``src/AppBundle/Service`` directory will automatically be added to
the container. Each service's "key" is simply its class name. You can use it immediately
inside your controller::

Choose a reason for hiding this comment

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

should we encourage type hinting arguments on the action method instead of using "get"?
fading out container->get provides many benefits, both at the design level and at the perf level (container optims of private services)

@javiereguiluz
Copy link
Member

Ryan, is there anything we can do to help you finishing these important changes? Thanks!

@weaverryan
Copy link
MemberAuthor

Other than the TODOs (which I would love help with), this is done. I really mean, we should merge it and continue on the other issues, as well as updating other docs now that we have autowiring and autoconfiguration (a lot of docs can change to take advantage of these).

There's one HUGE question we need to decide: do we continue to emphasize fetching services from the container by id? Or do we make a bigger change to fetch by instance.

For example, when we're talking about using the logger, I have:

usePsr\Log\LoggerInterface;publicfunctionindexAction(LoggerInterface$logger){// alternative way of getting the logger// $logger = $this->get('logger');}

I show both ways :). And we should... the first time. But now, if every other place where we need the logger, which should we show? We're transitioning from a system that is allid-based, to one that is type-based. Eventually, we need to make the jump. Showing the type, makes using servicesoutside of a controller easier.

Here's an example of how I would update the Doctrine doc if we made types the first-class citizen:weaverryan@dab49f4

Thoughts? There's a big job ahead to make the docs consistent with the new "types" model and autowiring. If we can choose our philosophy for 3.3, we can run and do that.

Thanks!

@weaverryanweaverryan changed the title[WIP] Updates to DI config for 3.3Updates to DI config for 3.3Apr 28, 2017
@nicolas-grekas
Copy link
Member

nicolas-grekas commentedApr 28, 2017
edited
Loading

I'm 👍 for fading out container injection. The new way makes the type of the deps plain explicit, yet still very easy to do. But I understand that this may not be shared by everyone (yet ;) ), so I'm not in a hurry to finish that rewrite. I'd be happy to have it finished when 3.4 is out, with a few months of experience behind us.

tystr reacted with thumbs up emoji

@theofidry
Copy link
Contributor

cc@TomasVotruba, you may be interested in this thread.

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 like it. Here are a few random comments, maybe wrong, so take just the parts that inspire you, if any.

:class:`Symfony\\Bundle\\FrameworkBundle\\Controller\\Controller` class.

..tip::
If you know what you're doing, you can alternatively extend

Choose a reason for hiding this comment

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

~~If you know what you're doing, ~~ : this just creates fear to me, whereas the diff is explained very simply in the next sentence, no?

Choose a reason for hiding this comment

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

just add that$this->get() is gone also?

Copy link
Contributor

Choose a reason for hiding this comment

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

I would reuse the wording of#7657:

The ``AbstractController`` class allows you to write a code more robust by preventing you from accessing the **service container**. This forces you to explicitly define your dependencies by using :doc:`the controller as a service </controller/service>`.

Services as Controller Arguments
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

You can also tell Symfony to pass your a service as a controller argument by type-hinting

Choose a reason for hiding this comment

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

"you" (not "your")

:doc:`Autowiring</service_container/autowiring>`. The key is the ``LoggerInterface``
type-hint in your ``__construct()`` method and the ``autowire: true`` config in
``services.yml``. When you type-hint an argument, the container will automatically
find the matching service. If it can't or there is any ambiguity, you'll see a clear

Choose a reason for hiding this comment

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

there won't be ambiguities anymore for interfaces (interfaces can be autowired by aliasing only now, when not using the deprecated mode). Dunno how that applies here :)

The ``LoggerInterface`` type-hint in the ``__construct()`` method is optional,
but a good idea. You can find the correct type-hint by reading the docs for the
service or by using the ``php bin/console debug:container`` console command.
How should you know to use ``LoggerInterface`` for the type-hint? The best way

Choose a reason for hiding this comment

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

there must be an alias for it (see previous comment)

:class:`Symfony\\Bundle\\FrameworkBundle\\Controller\\Controller` class.

..tip::
If you know what you're doing, you can alternatively extend
Copy link
Contributor

Choose a reason for hiding this comment

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

I would reuse the wording of#7657:

The ``AbstractController`` class allows you to write a code more robust by preventing you from accessing the **service container**. This forces you to explicitly define your dependencies by using :doc:`the controller as a service </controller/service>`.


As a developer, you might prefer not to extend the ``Controller``. To
use the flash message functionality, you can request the flash bag from
the:class:`Symfony\\Component\\HttpFoundation\\Session\\Session`::
Copy link
Contributor

Choose a reason for hiding this comment

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

Shouldn't this also be removed in thecontroller as a service article then?

Copy link
MemberAuthor

Choose a reason for hiding this comment

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

I think we need to re-read and re-think that article in its entirety... since controllers as services are a first-class citizen (does it make sense to still have a separate article?)

}

// you can also receive the $em as an argument
public function editAction(EntityManagerInterface $em)
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we also add this to theFetching Objects from the Database section? It doesn't seem obvious to me.

Copy link
MemberAuthor

Choose a reason for hiding this comment

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

I'll update the whole Doctrine section in another PR with more of this fancy type-based stuff :)

GuilhemN reacted with thumbs up emoji
</service>
</services>
</container>
TODO
Copy link
Contributor

Choose a reason for hiding this comment

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

        <?xml version="1.0" encoding="UTF-8" ?>        <containerxmlns="http://symfony.com/schema/dic/services"xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xsi:schemaLocation="http://symfony.com/schema/dic/services                http://symfony.com/schema/dic/services/services-1.0.xsd">            <services><!-- Default configuration for services in *this* file-->                <defaultsautowire="true"autoconfigure="true" /><!-- Load services from whatever directories you want (you can update this!)-->                <prototypenamespace="AppBundle\"resource="../../src/AppBundle/{Service,EventDispatcher,Twig,Form}" />            </services>        </container>

// app/config/services.php
use AppBundle\Service\MessageGenerator;
use Symfony\Component\DependencyInjection\Definition;
TODO
Copy link
Contributor

Choose a reason for hiding this comment

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

Prototypes don't exist for php code so imo we should either remove this doc block or let the current one with a comment explaining that it's not possible to register entire folders as with other loaders.


Above, we've set ``autoconfigure: true`` in the ``_defaults`` section so that it
applies to all services defined in that file. With this setting, the container will
automatically apply certain configuration to your services, based on your service's
Copy link
Contributor

Choose a reason for hiding this comment

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

configurations? ora certain configuration?

..code-block::xml
<!-- app/config/services.xml-->
TODO
Copy link
Contributor

Choose a reason for hiding this comment

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

        <?xml version="1.0" encoding="UTF-8" ?>        <containerxmlns="http://symfony.com/schema/dic/services"xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xsi:schemaLocation="http://symfony.com/schema/dic/services                http://symfony.com/schema/dic/services/services-1.0.xsd">            <services><!-- ...-->                <serviceid="AppBundle\Twig\MyTwigExtension">                    <tagname="twig.extension" />                </service>            </services>        </container>

autowire:true
autoconfigure:true
# load your service from the Twig directory
Copy link
Contributor

Choose a reason for hiding this comment

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

load your services?

..code-block::xml
<!-- app/config/services.xml-->
TODO
Copy link
Contributor

Choose a reason for hiding this comment

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

        <?xml version="1.0" encoding="UTF-8" ?>        <containerxmlns="http://symfony.com/schema/dic/services"xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xsi:schemaLocation="http://symfony.com/schema/dic/services                http://symfony.com/schema/dic/services/services-1.0.xsd">            <services>                <defaultsautowire="true"autoconfigure="true" /><!-- Load your services-->                <prototypenamespace="AppBundle\"resource="../../src/AppBundle/{Service,EventDispatcher,Twig,Form}" />            </services>        </container>

That's it! The container will find your class in the ``Twig/`` directory and register
it as a service. Then ``autoconfigure`` will add the ``twig.extension`` tag *for*
you, because your class implements ``Twig_ExtensionInterface``. And thanks to ``autowire``,
you can even add ``__construct()`` arguments without any configuration.
Copy link
Contributor

Choose a reason for hiding this comment

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

constructor arguments?

autowire:true
autoconfigure:true
# load services from whatever directories you want (you can update this!)
Copy link
Contributor

Choose a reason for hiding this comment

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

Should beloads to be consistent with other comments in the standard edition.

@weaverryan
Copy link
MemberAuthor

It looks like we'll likely addpublic: false to the SE -https://github.com/symfony/symfony-standard#1064 (and this is definitely set in Flex). That means it's time to treat "types" as the first-class citizen, and mention ids secondarily. I'm going to finish this PR as-is. Then, hopefully several of us can work together on the rest of the docs :) - i.e. scanning them and updating things to use a more type-based approach. Again, this should be a good reference of at least what I have in mind:weaverryan@dab49f4

GuilhemN reacted with thumbs up emoji

fabpot added a commit to symfony/symfony-standard that referenced this pull requestMay 1, 2017
This PR was merged into the 3.3-dev branch.Discussion----------Use symfony 3.3 featuresWith [Flex coming](https://github.com/symfony/recipes/blob/master/symfony/framework-bundle/3.3/etc/packages/app.yaml) and [the refactoring of the docs](symfony/symfony-docs#7807), I think we should push sf 3.3 di features and also begin to accustom people to sf 4.0 ideas.ping@weaverryanCommits-------7382e42 Use symfony 3.3 features
weaverryanand others added5 commitsMay 2, 2017 05:52
* origin/di-3.3-changes:  Add xml files  bad link  fixing build problem  last tweaks from feedback  Adding details and usages of fetching the service as a controller arg  adding note about autoconfigure  more tweaks  [WIP] Updates to DI config for 3.3
* origin/master:  Document ContainerBuilder::autowire()
@weaverryan
Copy link
MemberAuthor

Ready for one more review!

  • versionadded added
  • updated to make type-based a first-class citizen (over ids)

You can extend either ``Controller`` or ``AbstractController``. The difference
is that when you extend ``AbstractController``, you can't access services directly
via ``$this->get()`` or ``$this->container->get()``. This forces you to write
more robust code to access services, but if you're not use, use ``Controller``.
Copy link
Contributor

@GuilhemNGuilhemNMay 2, 2017
edited
Loading

Choose a reason for hiding this comment

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

I would reverse this sentence:but if you're use to fetch dependencies using the container, use Controller, wdyt?

Copy link
Contributor

@GuilhemNGuilhemN left a comment

Choose a reason for hiding this comment

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

Really nice improvement, thanks!

any other "work" you can think of. When you install a new bundle, it probably
brings in even *more* services.
..versionadded::3.3
The ability to type-hint an argument in order to receive a service was added
Copy link
Contributor

Choose a reason for hiding this comment

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

a controller argument?

any other "work"youcan think of.

$templating = $this->get('templating');
If you need a service, just type-hint an argument with its class (or interface) name.
Copy link
Contributor

@GuilhemNGuilhemNMay 2, 2017
edited
Loading

Choose a reason for hiding this comment

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

Shouldn't we explicit that this is only for controllers?

action:numberAction
argument:logger
# pass this specific service id
id:monolog.logger.doctrine
Copy link
Contributor

@GuilhemNGuilhemNMay 2, 2017
edited
Loading

Choose a reason for hiding this comment

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

Just as a reminder for me, I think it could be nice to be able to use bindings here.

Copy link
MemberAuthor

Choose a reason for hiding this comment

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

I also like bindings... we'll see how everything works out for in reality in Symfony 3.3 :). For the most part, bindings and arguments accomplish the same task (in a slightly different way). But it's interesting that bindings could also work to help with controller args - I hadn't really thought about that... seems like one use-case that makes bindings actually a bit better.

GuilhemN reacted with thumbs up emoji

..note::
If this isn't working, make sure your controller is registered as a service,
:ref:`autoconfigured<services-autoconfigure>` and extends either
Copy link
Contributor

Choose a reason for hiding this comment

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

Wouldn't, is autoconfigured be nicer?

Accessing the Container Directly
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

If extending the base ``Controller`` class, you can access any Symfony service
Copy link
Contributor

Choose a reason for hiding this comment

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

if you extend?

# same as before
AppBundle\:
resource:'../../src/AppBundle/{Service,Updates}'
Copy link
Contributor

Choose a reason for hiding this comment

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

was{Service,Updates,EventDispatcher,Twig,Form} actually :)

<!-- ...-->
<!-- Registers all classes in Services & Updates directories-->
<prototypenamespace="AppBundle\"resource="../../src/AppBundle/{Service,Updates,EventDispatcher,Twig,Form}" />
Copy link
Contributor

Choose a reason for hiding this comment

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

shouldn't we add all directories supported in the standard edition ({Command,Form,EventSubscriber,Twig,Security})?

<!-- ...-->
<!-- Same as before-->
<prototypenamespace="AppBundle\"resource="../../src/AppBundle/{Service,Updates}" />
Copy link
Contributor

Choose a reason for hiding this comment

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

same here

MessageGenerator::class,
array(new Reference('logger'), '%enable_generator_logging%')
));
$container->autowire(SiteUpdateManager::class)
Copy link
Contributor

Choose a reason for hiding this comment

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

missing use statement

Above, we've set ``autoconfigure: true`` in the ``_defaults`` section so that it
applies to all services defined in that file. With this setting, the container will
automatically apply certain configuration to your services, based on your service's
*class*. The is mostly used to *auto-tag* your services.
Copy link
Contributor

Choose a reason for hiding this comment

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

This

:ref:`autoconfigured<services-autoconfigure>` and extends either
:class:`Symfony\\Bundle\\FrameworkBundle\\Controller\\Controller` or
:class:`Symfony\\Bundle\\FrameworkBundle\\Controller\\AbstractController`. Or,
you can tag your service manually with ``controller.service_arguments``.
Copy link
Contributor

Choose a reason for hiding this comment

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

I would replace this byif you want to inject dependencies using arguments, your service has to be tagged with controller.service_arguments (already done in the standard edition).

fabpot added a commit to symfony/symfony that referenced this pull requestMay 4, 2017
This PR was squashed before being merged into the 3.3-dev branch (closes#22624).Discussion----------debug:container --types (classes/interfaces)| Q             | A| ------------- | ---| Branch?       | master| Bug fix?      | no| New feature?  | yes| BC breaks?    | no| Deprecations? | no| Tests pass?   | yes| Fixed tickets | none, but needed insymfony/symfony-docs#7807| License       | MIT| Doc PR        | n/aIn Symfony 3.3, the *type* (i.e. class/interface) is the most important thing about a service. But, we don't have a way for the user to know *what* types are available. This builds on top of `debug:container` to make `debug:container --types`:<img width="1272" alt="screen shot 2017-05-03 at 3 42 37 pm" src="https://cloud.githubusercontent.com/assets/121003/25678671/8bebacaa-3018-11e7-9cf6-b7654e2cae88.png">I think we need this for 3.3, so I've made the diff as *small* as possible. We could make improvements for 3.4, but just *having* this is the most important. I could even remove `format` support to make the diff smaller.~~This depends on#22385, which fixes a "bug" where private services aren't really shown.~~Thanks!Commits-------25a39c2 debug:container --types (classes/interfaces)

Accessing otherServices
~~~~~~~~~~~~~~~~~~~~~~~~
FetchingServices as Arguments
Copy link
Member

Choose a reason for hiding this comment

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

we should addd an anchor for the old headline

$ php bin/console debug:container
For more information, see the:doc:`/service_container` article.
If need to control the *exact* value of an argument, you can override your controller's
Copy link
Member

Choose a reason for hiding this comment

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

Ifyou need controlover the [...]


If you receive an eror like:

You have requested a non-existent service "my_service_id"
Copy link
Member

Choose a reason for hiding this comment

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

This will render the error message as a block quote. Do we really want that? I suggest to use atext code block instead.


controller/*

.. _`helper methods`:https://github.com/symfony/symfony/blob/master/src/Symfony/Bundle/FrameworkBundle/Controller/ControllerTrait.php
Copy link
Member

Choose a reason for hiding this comment

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

What about document the trait in the reference section instead?

Copy link
MemberAuthor

Choose a reason for hiding this comment

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

I'm not sure why, but the API docs for the trait areterrible, basically empty :/. It's actually a problem because Iwould like to link to some methods in the trait via:method in a few places -http://api.symfony.com/master/Symfony/Bundle/FrameworkBundle/Controller/ControllerTrait.html

* origin/master: (36 commits)  Use the short Yaml syntax for service definition  [#7613] remove reference to AsseticBundle  minor#7613 Twig Extensions Reference minor brush-up (mpdude)  Fix service locator declaration  Minor reword  Update Title in controller.rst  Update scheme.rst  Update requirements.rst  [3.3] Document FQCN named controllers  Document FQCN named controllers  Use the short tag syntax  [#7845] minor tweaks  Update translation_domain.rst.inc  Update page_creation.rst to correct hidden colon  Update forms.rst  Rewords  Fixed the form types of the buttons in the Form reference  [#7832] use bin/console for Symfony 3.x  Minor reword  Update deployment.rst  ...
@weaverryanweaverryan merged commit22adfbd intomasterMay 5, 2017
weaverryan added a commit that referenced this pull requestMay 5, 2017
This PR was merged into the master branch.Discussion----------Updates to DI config for 3.3Hi guys!WIP changes the new DI changes in 3.3! Woohoo! Some notes for myself:This relates to, oh, just these 10+ issues :). Assume they will all be closed by this one PR - before merge, if any of them aren't covered, I'll remove them.TODOS later (some might already be done)- update to use `debug:container --types` (symfony/symfony#22624)- update all other documents for possible changes for autowiring and autoconfigure- new page for existing Symfony users to explain the changes- update autowire section to talk about using aliases- document instanceof and also the ability to add configuration to the PSR4 loader- some links in the controller go to the API docs of `Controller`. But this is wrong, the methodsnow live in `ControllerTrait`... but the API docs for traits is basically broken:http://api.symfony.com/master/Symfony/Bundle/FrameworkBundle/Controller/ControllerTrait.html- how should we pass a parameter to a controller?- do Twig extensions still need to be public? If so, the example in `service_container` about autoconfigure is still not quite rightDefinitely included in this PR*#7544*#7482*#7339*#7672Not included in this PR (but related to DI changes)*#7329*#7782*#7777*#7706*#7608*#7538*#7441*#7255* ~~#7041~~* ~~#7445~~* ~~#7444~~* ~~#7436~~Commits-------22adfbd removing duplicate target12c4944 Tweaks after amazing review from@GuilhemN and@xabbuhcac3c6c Merge remote-tracking branch 'origin/master' into di-3.3-changes2229fd3 Merge remote-tracking branch 'origin/master' into di-3.3-changes5452c61 Adding section about public: falseee27765 Adding versionaddedbc7088d Merge remote-tracking branch 'origin/di-3.3-changes' into di-3.3-changes443aec2 Merge pull request#7857 from GuilhemN/patch-189e12de bad link6de83e2 fixing build problem759e9b2 last tweaks from feedback45500b3 Adding details and usages of fetching the service as a controller arg70178d1 adding note about autoconfigure6e6ed94 more tweaks0e48bd8 [WIP] Updates to DI config for 3.39ab27f0 Add xml files2636bea bad linkc45daf4 fixing build problem9e84572 last tweaks from feedback049df7d Adding details and usages of fetching the service as a controller arg105801c adding note about autoconfigure2d11347 more tweaks8433fc1 [WIP] Updates to DI config for 3.3
@weaverryanweaverryan deleted the di-3.3-changes branchMay 5, 2017 15:36
@weaverryan
Copy link
MemberAuthor

Merged! Thank you guys for the WONDERFUL reviews!

Now, we need to continue to attack the 3.3 milestone issueshttps://github.com/symfony/symfony-docs/milestone/13 and basically review each document in the docs to make sure it's following the "types-first" philosophy. So, lot's to do still :)

Cheers!

GuilhemN reacted with hooray emoji

# loads services from whatever directories you want (you can update this!)
AppBundle\:
resource:'../../src/AppBundle/{Service,Command,Form,EventSubscriber,Twig,Security}'
Copy link
Contributor

@theofidrytheofidryMay 12, 2017
edited
Loading

Choose a reason for hiding this comment

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

sorry for being late, but what about giving an absolute path here with%kernel.root_dir% for example? I always find those relative paths a bit confusing as it's not always obvious relative to what. Alternatively, maybe we should add an example with both:

AppBundle\:# glob with path relative to this fileresource:'../../src/AppBundle/{Service,Command,Form,EventSubscriber,Twig,Security}'# orresource:'%kernel.root_path%/../../src/AppBundle/{Service,Command,Form,EventSubscriber,Twig,Security}'

The case above may not be a good one since it makes it extra verbose, but I've seen quite a few projects where they are using a custom parameter to point tosrc, making it less verbose. Either way, you're still showing that parameters are supported in the glob.

Also I don't see anywhere mentioned that it's a glob that's being used.

Choose a reason for hiding this comment

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

%kernel.project_dir% might be even simpler

'%kernel.project_dir%/src/AppBundle/{Service,Command,Form,EventSubscriber,Twig,Security}'

Copy link
Contributor

Choose a reason for hiding this comment

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

Even better, I forgot we were adding this in 3.3!

Copy link
Contributor

Choose a reason for hiding this comment

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

I don't see a big gain, that makes one more thing to learn for newcomers while relative paths are understandable by everyone.

@theofidry
Copy link
Contributor

theofidry commentedMay 12, 2017 via email

I find relative paths more'confusing than absolute ones, but that be justme and my personal experiences
On Fri, 12 May 2017 at 22:16, Guilhem Niot ***@***.***> wrote: ***@***.**** commented on this pull request. ------------------------------ In service_container.rst <#7807 (comment)>: > @@ -133,9 +147,15 @@ the service container *how* to instantiate it: # app/config/services.yml services: - app.message_generator: - class: AppBundle\Service\MessageGenerator - arguments: [] + # default configuration for services in *this* file + _defaults: + autowire: true + autoconfigure: true + public: false + + # loads services from whatever directories you want (you can update this!) + AppBundle\: + resource: '../../src/AppBundle/{Service,Command,Form,EventSubscriber,Twig,Security}' I don't see a big gain, that makes one more thing to learn for newcomers while relative paths are understandable by everyone. — You are receiving this because you commented. Reply to this email directly, view it on GitHub <#7807 (comment)>, or mute the thread <https://github.com/notifications/unsubscribe-auth/AE76gc8gncxhlGFmzTfvzY_kQ1H8ipqaks5r5MxAgaJpZM4M-aD_> .

@xabbuh
Copy link
Member

At least, the documentation example is consistent with the default configs in the Standard Edition and when installing the FrameworkBundle using Flex. If we were to make the change, I would first discuss it where the default configs are provided.

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

Reviewers

@javiereguiluzjaviereguiluzjaviereguiluz left review comments

@nicolas-grekasnicolas-grekasnicolas-grekas left review comments

@xabbuhxabbuhxabbuh left review comments

+3 more reviewers

@BPScottBPScottBPScott left review comments

@theofidrytheofidrytheofidry left review comments

@GuilhemNGuilhemNGuilhemN left review comments

Reviewers whose approvals may not affect merge requirements

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

8 participants

@weaverryan@javiereguiluz@nicolas-grekas@theofidry@xabbuh@BPScott@GuilhemN

[8]ページ先頭

©2009-2025 Movatter.jp