我们在Symfony2中使用下面的包来创建一个RESTful API。控制器必须返回一个响应(对象(Symfony Component Form Form)给出)
new FOS\RestBundle\FOSRestBundle(),
new JMS\SerializerBundle\JMSSerializerBundle(),
new Nelmio\ApiDocBundle\NelmioApiDocBundle(),
我们得到下面的错误运行PHP后composer.phar更新
[2014-12-05 10:39:41] security.INFO: Populated SecurityContext with an anonymous Token [] []
[2014-12-05 10:39:41] request.CRITICAL: Uncaught PHP Exception LogicException: "The controller must return a response (Object(Symfony\Component\Form\Form) given)." at /var/www/html/symfony2/app/bootstrap.php.cache line 3020 {"exception":"[object] (LogicException: The controller must return a response (Object(Symfony\\Component\\Form\\Form) given). at /var/www/html/symfony2/app/bootstrap.php.cache:3020)"} []
[2014-12-05 10:39:41] security.DEBUG: Write SecurityContext in the session [] []
我们使用以下步骤
//install symfony
php composer.phar create-project symfony/framework-standard-edition symfony2/
//move composer into symfony folder
cp composer.phar symfony2/composer.phar
rm composer.phar
cd symfony2
//symfony dependencies
php composer.phar require doctrine/doctrine-fixtures-bundle
php composer.phar require "friendsofsymfony/rest-bundle" "@dev"
php composer.phar require "jms/serializer-bundle" "@dev"
php composer.phar require "nelmio/api-doc-bundle" "@dev"
的API请求将返回500服务器在我们的服务器上安装的Symfony2错误。
由于我不确定它为什么不起作用,我已经将错误追溯到下面的点。
@Annotations\View(
templateVar = "form"
)
ClassResourceInterface类负责以上操作。
这可能涉及到这个问题,但在此发布的解决方案不起作用:
FOSRestBundle: The controller must return a response (Array()) given
东西是不对的类:
Nelmio\ApiDocBundle\Annotation\ApiDoc
有没有人有这个问题,因为好?
谢谢
什么的'Annotations'别名您使用的语句? – 2014-12-06 19:25:05
@WouterJ你用什么声明来表示? – pppglowacki 2014-12-08 08:18:46