Skip to content
Advertisement

Unable to find template error in Symfony 3.4

When I upgraded the system running Symfony3.0 to version 3.4, the following error occured.
I’ve tried php bin/console debug:router php bin/console debug:twig , but the routing doesn’t seem to be a problem. What else should I consider?

Error Code

Unable to find template "@AhiSpAdmin/hq/analytics/shop.html.twig" (looked into: /home/Symfony/src/AppBundle/Resources/views).

Code
Controller.php

/**
 * @Route("/hq/analytics")
 */
class AnalyticsController extends BaseAnalyticsController
{

    protected $staffRoute = "ahi_sp_admin_hq_analytics_staff";
    protected $articleRoute = "ahi_sp_admin_hq_analytics_article";

    /**
     * @Route("/shop/", defaults={"_format"="html"}, requirements={"_format"="html|csv"})
     * @Method("GET")
     *  
     * @Template()
     */
    public function shopAction(Request $request)
    {
        // Add Form
        $searchForm = $this->createForm(ShopMetricsSearchType::class, null, array(
            'action' => $this->generateUrl('ahi_sp_admin_hq_analytics_shop'),
        ));
    }

routing.yml

ahi_sp_admin:
    resource: "@AppBundle/Controller/"
    type:     annotation
    prefix:   /admin/
    schemes:  ["%secure_scheme%"]

config.yml

framework:
    templating:
        engies: ['twig']

index.html.twig

<a href="{{ path('ahi_sp_admin_shop_analytics_article', {
}) }}">

Version
Symfony 3.4.47 PHP 7.3

Advertisement

Answer

It was solved by specifying twig for @Template. Thanks to gview.

    /**
     * @Route("/shop/", defaults={"_format"="html"}, requirements={"_format"="html|csv"})
     * @Method("GET")
     *  
     * @Template("AppBundle:Hq/Analytics:shop.html.twig")
     */
User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement