Symfony / Twig:无法找到模板

时间:2018-11-08 12:47:22

标签: php symfony twig

我是Symfony和Twig的新手。我在Twig遇到问题。

我总是遇到以下错误

  

无法找到模板“ BackendBackofficeBundle :: base.html.twig”(查找到:C:\ Users \ Username \ Documents \ NetBeansProjects \ idno_backoffice \ app / Resources / views,C:\ Users \ Username \ Documents \ NetBeansProjects第1行的@BackendBackoffice \ consultant \ index.html.twig中的\ idno_backoffice \ vendor \ symfony \ symfony \ src \ Symfony \ Bridge \ Twig / Resources / views / Form)。

我的index.html.twig看起来像

{% extends 'BackendBackofficeBundle::base.html.twig' %}
{% block body %}
<div class="row">           
    <div class="col-md-12">
        <div class="panel panel-default">
            <div class="panel-heading">Search .../<div>
                <div class="panel-body">
                <div class="input-group">
                    <input type="text" class="form-control">
                    <div class="input-group-btn">
                        <button class="btn btn-default" type="button">Go!</button>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
<div class="row">           
    <div class="col-md-12">
        <div class="panel panel-default">
            <div class="panel-heading">Overview</div>
            <div class="panel-body">
                <p>No Tickets</p>
            </div>
            <table class="table">
                <thead>
                    <tr>
                        <th>ID</th>
                        <th>Subject</th>
                        <th>Customer</th>
                        <th>Created_at</th>
                    </tr>
                </thead>
            </table>
        </div>
    </div>
</div>
{% endblock %}

我的base.html.twig看起来像

<!DOCTYPE html>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset={{ _charset }}"/>
    <meta name="robots" content="noindex,nofollow"/>
    <title>{% block title %}Backoffice{% endblock %}</title>
    <link rel="stylesheet" href="{{ asset('bundles/backendbackoffice/bootstrap/css/bootstrap.min.css') }}"/>
    <link rel="stylesheet" href="{{ asset('bundles/backendbackoffice/bootstrap/css/bootstrap-theme.min.css') }}"/>
    <link rel="stylesheet" href="{{ asset('bundles/backendbackoffice/backoffice/css/main.css') }}"/>
    {% block head %}{% endblock %}
</head>
<body role="document">

    <!-- navbar -->
    <nav class="navbar navbar-default">
        <div class="container">
            <div class="navbar-header">
                <button type="button" class="navbar-toggle collapsed"
                        data-toggle="collapse" data-target="#menu-toggle">
                    <span class="sr-only"></span>
                    <span class="icon-bar"></span>
                    <span class="icon-bar"></span>
                    <span class="icon-bar"></span>
                </button>
                <a class="navbar-brand" href="/">Test 1</a>
            </div>

            <!-- Collect the nav links, forms, and other content for toggling -->
            <div class="collapse navbar-collapse" id="menu-toggle">
                <ul class="nav navbar-nav">
                    <li><a href="#">Overview</a></li>
                </ul>
            </div>
            <!-- /.navbar-collapse -->
        </div>
        <!-- /.container-fluid -->
    </nav>
    <!-- /navbar -->

    <div class='container'>
        {% block body %}{% endblock %}
    </div>

    {% block javascripts %}
        <script src="//code.jquery.com/jquery-1.9.1.min.js"></script>
        <script src="{{ asset('bundles/backendbackoffice/bootstrap/js/bootstrap.min.js') }}" type="text/javascript"></script>
    {% endblock %}

</body>

</html>

有人可以帮助我吗?我不知道为什么我的index.html.twig找不到我的base.html.twig

如果您需要更多文件,请告诉我。

1 个答案:

答案 0 :(得分:0)

如果您使用的是symfony 3.4,则应包含config / config.yml

framework:
    templating:
        engines: ['twig']

在运行之后

作曲家安装