最近使用 Symfony3.0 开发项目的时候,发现在之前的 Symfony 2.x 版本的,在注入服务的时候可以使用下列方法:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd"> |
结果到了使用 Symfony 3.0 的时候,使用同样的方法进行注入的时候,会报一下错误:
1 2 3 4 5 6 7 8 9 10 11 12 13 |
InvalidArgumentException in XmlUtils.php line 96: [ERROR 1866] Element '{http://symfony.com/schema/dic/services}service', attribute 'factory-service': The attribute 'factory-service' is not allowed. (in file:///E:/webroot/blog/web/ - line 19, column 0) [ERROR 1866] Element '{http://symfony.com/schema/dic/services}service', attribute 'factory-method': The attribute 'factory-method' is not allowed. (in file:///E:/webroot/blog/web/ - line 19, column 0) |
结果仔细看文档,才发现 3.0版本已经没有这种写法了,需要做如下调整 :
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd"> |