문제

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