TYPO3-Documentation / TYPO3CMS-Reference-CoreApi

"TYPO3 Explained": Main TYPO3 Core Document: Main classes, Security, TypoScript syntax, Extension API and much more
https://docs.typo3.org/m/typo3/reference-coreapi/master/en-us/
21 stars 370 forks source link

Document DI Autoconfigure attribute for public/shared = true as alternative to Services.yaml #4539

Open brotkrueml opened 2 weeks ago

brotkrueml commented 2 weeks ago

TYPO3 supports the Autoconfigure attribute for declaring a class as public/shared, for example:

use Symfony\Component\DependencyInjection\Attribute\Autoconfigure;

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

This should be documented in the DI chapter where "public" is explained as alternative to declaring in Services.[yaml|php].

See also: https://review.typo3.org/c/Packages/TYPO3.CMS/+/84676

This works also in TYPO3 v12 with at least Symfony 7 (I assume also Symfony 6, but has to be tested). The attribute itself was introduced with Symfony 5.3, so this may also work in TYPO3 v11.