最近开发symfony3项目的时候,发现当使用brew安装的PHP7.1版本运行,总是会提示var目录下 failed to open stream: Permission denied 错误,当把PHP的php-fpm运行权限改对后,又发现Wordpress项目的后台打开总是出现504错误. 反正就是两个项目不能同时正确的运行,结果搞了很久都没搞定,去官网找了找才发现有这么一篇文章 Using...
最近使用 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版本已经没有这种...
在symfony2中如何将controller定义为一个service ,并在路由配置文件中使用定义的控制器服务呢?其实很简单,就像把其他的类定义为服务一样......
首先创建一个 bundle,
php app/console generate:bundle --namespace=Vshop/Bundle/CoreBundle --format=xml
然后打开 CoreBundle 里面的这个 service 文件 src/Vshop/Bundle/CoreBundle/Resources/config/services.xml
我的项目配置文件进行了分割,方便以后的管理,目录结构如下......
1.使用composer包管理工具进行安装. composer create-project symfony/framework-standard-edition 2. 创建一个Bundle php app/console generate:bundle --namespace=Themetouch/Bundle/AdminBundle --format=yml 3. 安装资源文件到web目录下 ...