PHP and autoloading · Question 8 of 12
In a Composer-based TYPO3 installation, where do you define in which directory the classes of an extension's namespace are located?
1 answer is correct. Easy
Show answer
Answer
- B In the autoload section of the extension's composer.json
Explanation
The namespace mapping belongs in the extension's composer.json, for example "autoload": {"psr-4": {"MyVendor\. Composer reads this during installation and adds it to the project autoloader; if you change the mapping later, composer dump-autoload is required. Services.yaml, on the other hand, controls dependency injection, i.e. which classes are configured as services, and it already assumes working autoloading. ext_localconf.php and settings.php contain runtime configuration, not settings for the autoloader.