mirror of https://github.com/FriendsOfTYPO3/tea.git synced 2024-11-10 00:16:13 +01:00
tea/Documentation/DivergencesToTypo3Core/ServicesFiles.rst
Daniel Siepmann b8ef4383b7
[TASK] Migrate from Services.yaml to Services.php (#1286)
* Migrate existing configuration from yaml to php.
* Document why we did the switch and that using yaml or both is totally
  valid and conforms to best practices.
* Document why we are not using attributes but only `Services.php`
  right now.

Resolves: #1172
Relates: #1237
2024-05-07 14:14:54 +02:00

963 B

Services Files

We choose to use Services.php instead of Services.yaml. It still is completely fine to use YAML files over PHP files or even mix both. Some things are way shorter to write with the YAML syntax.

We prefer the PHP file over YAML for the following reasons:

  • Static Code Analysis

    Static code analysis tools, like PHPStan, can analyse the PHP source code base. They typically don't support other files like YAML. Those tools report issues for not found classes, e.g. due to typos.

  • Auto completion

    Modern tooling like IDEs and Language Servers provide auto completion for PHP source files out of the box. That way programmers can discover APIs and write more robust code faster.

  • Automatic code migration

    PHP Code can be auto migrated via tools like rector. E.g. renaming a class can be applied to PHP code, but no current tool for yaml exists.