Skip to content

Commit

Permalink
Merge branch '7.0' into 7.1
Browse files Browse the repository at this point in the history
* 7.0:
  [DI] Mark service as public with #[Autoconfigure] attribute
  • Loading branch information
javiereguiluz committed Jun 21, 2024
2 parents c7b7abd + ab883ae commit 2bd8243
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 0 deletions.
15 changes: 15 additions & 0 deletions service_container.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1111,6 +1111,21 @@ setting:
;
};
It is also possible to define a service as public thanks to the ``#[Autoconfigure]``
attribute. This attribute must be used directly on the class of the service
you want to configure::

// src/Service/PublicService.php
namespace App\Service;

use Symfony\Component\DependencyInjection\Attribute\Autoconfigure;

#[Autoconfigure(public: true)]
class PublicService
{
// ...
}

.. _service-psr4-loader:

Importing Many Services at once with resource
Expand Down
15 changes: 15 additions & 0 deletions service_container/alias_private.rst
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,21 @@ You can also control the ``public`` option on a service-by-service basis:
->public();
};
It is also possible to define a service as public thanks to the ``#[Autoconfigure]``
attribute. This attribute must be used directly on the class of the service
you want to configure::

// src/Service/Foo.php
namespace App\Service;

use Symfony\Component\DependencyInjection\Attribute\Autoconfigure;

#[Autoconfigure(public: true)]
class Foo
{
// ...
}

.. _services-why-private:

Private services are special because they allow the container to optimize whether
Expand Down

0 comments on commit 2bd8243

Please sign in to comment.