我使用的是组件(版本2.7),而不是symfony框架。
我正在使用PHP注入,但没关系,但我决定使用XML。我不知道如何将XML存储服务加载到ContainerBuilder对象中,
我正在以这种方式使用该组件:
$container = new ContainerBuilder();
$container->setDefinition('Crypt', new Definition('MiladRahimi\PHPCrypt\Crypt'));
答案 0 :(得分:0)
该组件为nicely documented。您可以在官方文档中找到所需的一切。
具体来说,请阅读Setting up the Container with Configuration Files和Compiling the container。请务必dump the container for better performance。
以下是从文档中加载xml文件的示例:
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\Config\FileLocator;
use Symfony\Component\DependencyInjection\Loader\XmlFileLoader;
$container = new ContainerBuilder();
$loader = new XmlFileLoader($container, new FileLocator(__DIR__));
$loader->load('services.xml');