Joel Harkes
Joel Harkes

Reputation: 11661

Symfony new bundle unable to find template

I made a new bundle routing.yml:

_jihtest:
    pattern: /test
    defaults: { _controller: JihTest:Index:index }

create file directory /src/Jih/Test/... (eg. /src/Jih/Test/Recources/views/Index/index.html.twig)

i might an Indexcontroller:

class IndexController extends Controller{

    public function indexAction() {

        return $this->render('JihTest:Index:index.html.twig');

    }

}

but when go to the link it says: Unable to find template "JihTest:Index:index.html.twig".

what did i do wrong/forgot?

Upvotes: 2

Views: 22559

Answers (2)

Vadim Ashikhman
Vadim Ashikhman

Reputation: 10136

Controller's name matches the name of a folder. In your case the folder name starts with lowercase character "i". Rename it to "Index".

Upvotes: 5

Erioch
Erioch

Reputation: 359

The bundle name must end with Bundle, in your case:

_jihtest:
    pattern: /test
    defaults: { _controller: JihTestBundle:Index:index }

And

class IndexController extends Controller{

    public function indexAction() {

        return $this->render('JihTestBundle:Index:index.html.twig');

    }
}

Upvotes: 4

Related Questions