Default location to Twig templates is app/Resources/views but if you wish to change it to classic path src/AppBundle/Resources/views then add following line to configuration file.


# app/config/config.yml

twig:
...
paths: ["%kernel.project_dir%/src/AppBundle/Resources/views"]

If you inject @templating service into your controller to serve Twig templates then add following line to configuration file.


# app/config/config.yml

framework:
templating:
engines: ['twig']

After these changes, you can have a controller like show below.


namespace AppBundle\Controller;

use Symfony\Bundle\FrameworkBundle\Templating\EngineInterface;
use Symfony\Component\HttpFoundation\Response;

class DefaultController
{
private $templating;

public function __construct(EngineInterface $templating)
{
$this->templating = $templating;
}

public function indexAction()
{
$template = $this->templating->render('AppBundle:default:index.html.twig', [...]);

return (new Response())->setContent($template);
}
}

# src/AppBundle/Resources/views/default/index.html.twig

{% extends '::base.html.twig' %}

{% block body %}
Default
{% endblock %}