Symfony Unable to find template "BlogBundle :: home.html.twig"

1

I am learning symfony 3.4 and I am trying to link a route with a view. When I run the program using the route:

http://127.0.0.1:8000/home

It generates the following: Unable to find template "BlogBundle :: home.html.twig"

My routing.yml file is as follows:

blog:
    resource: "@BlogBundle/Controller/"
    type:     annotation
    prefix:    /

app:
    resource: "@AppBundle/Controller/"
    type: annotation

My driver is as follows:

<?php

    namespace BlogBundle\Controller;

    use Symfony\Component\HttpFoundation\Response;
    use Symfony\Bundle\FrameworkBundle\Controller\Controller;
    use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
    use Sensio\Bundle\FrameworkExtraBundle\Configuration\Method;

    class DefaultController extends Controller
    {
         /**
          * @Route("/home",name="home_route")
          *  @Method({"GET"})
          */
         public function indexAction()
         {
            //esta sentencia funciona
            //return new Response('<html><body>hola mundo</body></html>' );

            //
            return $this->render('BlogBundle::inicio.html.twig');
         }

    }

My file inicio.html.twig is as follows:

Hello World!

If someone can guide me on how to solve this problem or any suggestion will be well received, I am a bit complicated and just beginning.

    
asked by Cristian Budzicz 06.02.2018 в 14:56
source

1 answer

1

Can you indicate where you have the incio.html.twig file? if not BlogBundle / config / resources / views

That may be the problem.

Edit:

The problem is that the route was not being set correctly:

BlogBundle::inicio.html.twig is correct when it is in the views folder, but if you want to put it in a "Default" folder you have to put BlogBundle:Default:inicio.html.twig .

    
answered by 10.02.2018 / 14:36
source