Hi Have followed the instructions to enable the SensioFrameworkExtraBundle here: http://symfony.com/doc/2.1/bundles/SensioFrameworkExtraBundle/index.html

Thereafter I create the below controller:

namespace Acme\DemoBundle\Controller;

use Sensio\Bundle\FrameworkExtraBundle\Configuration\Template;

class MyController
{
    /**
     * @Template
     */
    public function indexAction()
    {

    }
}

If set up a route pointing to the indexAction on this controller and browse to it, I get the following error:

The controller must return a response (null given). Did you forget to add a return statement somewhere in your controller?

It looks like the SensioFrameworkExtraBundle is not actually enabled, but I cannot figure out why. I'm looking for advice.

有帮助吗?

解决方案

The @Template annotation is working. As the error suggest, you must return something. If return array, it will be sent to template engine. Make sure the template exists.

public function indexAction()
{
    ...

    $somedata = 'fill data';
    return array('somedata' => $somedata);
}
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top