The YAML format does not support anonymous services (cf. the XML loader).
use Symfony\Component\DependencyInjection\Loader\YamlFileLoader; use Symfony\Component\Config\FileLocator; // Load the configuration file $loader = new YamlFileLoader($container, new FileLocator(__DIR__)); $loader->load('services.yaml');
# services.yaml services: logger: class: MyLogger arguments: - '@mailer' - '%logger.level%'In this example, we define a service named "logger" with the class "MyLogger" and two arguments: another service named "mailer" and a string parameter named "logger.level". Overall, the YamlFileLoader is a part of the Symfony component library for Dependency Injection, which aims to simplify the process of managing dependencies in large-scale projects. It supports various file formats, such as YAML, XML, and PHP, and allows developers to define and manage services, parameters, and other configuration options easily.