簡體   English   中英

在 Symfony 3.4 中找不到模板錯誤

[英]Unable to find template error in Symfony 3.4

當我將運行 Symfony3.0 的系統升級到 3.4 版本時,出現以下錯誤。
我試過php bin/console debug:router php bin/console debug:twig ,但路由似乎不是問題。 我還應該考慮什么?

錯誤代碼

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

代碼
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'),
        ));
    }

路由.yml

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

配置.yml

framework:
    templating:
        engies: ['twig']

索引.html.twig

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

版本
Symfony 3.4.47 PHP 7.3

通過為@Template指定 twig 解決了這個問題。 感謝gview。

    /**
     * @Route("/shop/", defaults={"_format"="html"}, requirements={"_format"="html|csv"})
     * @Method("GET")
     *  
     * @Template("AppBundle:Hq/Analytics:shop.html.twig")
     */

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM