Symfony2.4.1-在一个命令中生成具有操作的控制器失败
我想生成一个具有一系列操作的控制器,但只使用一个命令 我使用的命令是:Symfony2.4.1-在一个命令中生成具有操作的控制器失败,symfony,Symfony,我想生成一个具有一系列操作的控制器,但只使用一个命令 我使用的命令是: $ php app/console generate:controller --no-interaction --controller=Sample01DemoBundle:Demo1 --actions=helloAction:/hello:Sample01DemoBundle:Demo1:hello.html.twig --route-format=yml --template-format=twig 以下是错误输出:
$ php app/console generate:controller --no-interaction --controller=Sample01DemoBundle:Demo1 --actions=helloAction:/hello:Sample01DemoBundle:Demo1:hello.html.twig --route-format=yml --template-format=twig
以下是错误输出:
Controller generation
PHP Warning: Illegal string offset 'name' in /home/rocker/projects/sample01/vendor/sensio/generator-bundle/Sensio/Bundle/GeneratorBundle/Generator/ControllerGenerator.php on line 56
PHP Warning: Illegal string offset 'basename' in /home/rocker/projects/sample01/vendor/sensio/generator-bundle/Sensio/Bundle/GeneratorBundle/Generator/ControllerGenerator.php on line 56
PHP Warning: Illegal string offset 'template' in /home/rocker/projects/sample01/vendor/sensio/generator-bundle/Sensio/Bundle/GeneratorBundle/Generator/ControllerGenerator.php on line 61
PHP Notice: Undefined offset: 2 in /home/rocker/projects/sample01/vendor/sensio/generator-bundle/Sensio/Bundle/GeneratorBundle/Generator/ControllerGenerator.php on line 190
PHP Notice: Undefined offset: 1 in /home/rocker/projects/sample01/vendor/sensio/generator-bundle/Sensio/Bundle/GeneratorBundle/Generator/ControllerGenerator.php on line 190
[Twig_Error_Runtime]
Impossible to access an attribute ("basename") on a string variable ("elloAction:/hello/{id}:Sample01DemoB
undle:Demo1:hello.html.twig") in "controller/Template.html.twig.twig" at line 4
其他信息:
$ php app/console --version
Symfony version 2.4.1 - app/dev/debug
我做错了什么?
束生成工作正常
每一个想法都是显而易见的。谢谢。将引号用于操作参数:
--actions="helloAction:/hello:Sample01DemoBundle:Demo1:hello.html.twig"
另见:
UPD:
根据github,控制器生成器仅在symfony版本2.2.x之后可用。因此,如果您想使用controller generator,必须更新您的symfony副本。您使用的symfony版本是什么?2.1.4?@TrevorDonahue你的问题以前有标签
symfony2.4
,所以我有点困惑。我删除了它并更新了我的答案,请检查它。对不起。其实情况正好相反。简而言之,它是2.4.1,最新版本。我的错。我也犯了这个错误。你解决了吗?没有,还没有。显然我们是唯一得到这个的人。