File tree Expand file tree Collapse file tree 2 files changed +40
-0
lines changed Expand file tree Collapse file tree 2 files changed +40
-0
lines changed Original file line number Diff line number Diff line change @@ -927,6 +927,26 @@ setting:
927
927
;
928
928
};
929
929
930
+ It is also possible to define a service as public thanks to the ``#[Autoconfigure] ``
931
+ attribute. This attribute must be used directly on the class of the service
932
+ you want to configure::
933
+
934
+ // src/Service/PublicService.php
935
+ namespace App\Service;
936
+
937
+ use Symfony\Component\DependencyInjection\Attribute\Autoconfigure;
938
+
939
+ #[Autoconfigure(public: true)]
940
+ class PublicService
941
+ {
942
+ // ...
943
+ }
944
+
945
+ .. versionadded :: 5.3
946
+
947
+ The ``#[Autoconfigure] `` attribute was introduced in Symfony 5.3. PHP
948
+ attributes require at least PHP 8.0.
949
+
930
950
.. deprecated :: 5.1
931
951
932
952
As of Symfony 5.1, it is no longer possible to autowire the service
Original file line number Diff line number Diff line change @@ -62,6 +62,26 @@ You can also control the ``public`` option on a service-by-service basis:
62
62
->public();
63
63
};
64
64
65
+ It is also possible to define a service as public thanks to the ``#[Autoconfigure] ``
66
+ attribute. This attribute must be used directly on the class of the service
67
+ you want to configure::
68
+
69
+ // src/Service/Foo.php
70
+ namespace App\Service;
71
+
72
+ use Symfony\Component\DependencyInjection\Attribute\Autoconfigure;
73
+
74
+ #[Autoconfigure(public: true)]
75
+ class Foo
76
+ {
77
+ // ...
78
+ }
79
+
80
+ .. versionadded :: 5.3
81
+
82
+ The ``#[Autoconfigure] `` attribute was introduced in Symfony 5.3. PHP
83
+ attributes require at least PHP 8.0.
84
+
65
85
.. _services-why-private :
66
86
67
87
Private services are special because they allow the container to optimize whether
You can’t perform that action at this time.
0 commit comments