I am learning symfony 3.4 and I am trying to link a route with a view. When I run the program using the path:
http://127.0.0.1:8000/home
It generates the following: Unable to find template "BlogBundle::start.html.twig"
My routing.yml file is as follows:
blog:
resource: "@BlogBundle/Controller/"
type: annotation
prefix: /
app:
resource: "@AppBundle/Controller/"
type: annotation
My controller is the following:
<?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 the following:
Hello World!
If someone can guide me on how to solve this problem or any suggestion will be well received, I'm a bit complicated and I'm just starting.
Can you indicate where you have the incio.html.twig file? if not this 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
it is correct when it is in the views folder, but if you want to put it in a "Default" folder you have to putBlogBundle:Default:inicio.html.twig
.