我在Slim说
时遇到错误Message: An exception has been thrown during the rendering of a template
("Named route not found for name: userList") in "sidebar.twig" at line 7.
我的观点是
{% extends 'base.twig' %}
{% block title %} Índice {% endblock title %}
{% block content %}
<div class="row">
<div class="container">
{% include "sidebar.twig" %}
我的观点sidebar.twig如下:
<div class="col-lg-4 col-md-4 col-xs-4">
<div class="dropdown menu col-lg-9 col-md-9 col-xs-9">
<ul class="nav nav-pills nav-stacked">
<li><a tabindex="-1" href="#">GESTIÓN DE PARTICIPANTES</a></li>
{% if authorized %}
<li><a tabindex="-1" href="{{ urlFor('userList') }}">GESTION DE USUARIOS</a></li>
{% endif %}
</ul>
</div>
</div>
视图+模型的代码
$app->get('/users', function() use ($app, $authorized,$users)
{
$app->render('users.twig',array('users' => $users, 'is_admin' => $authorized));
})->name('userList');
github中的代码是=&gt; https://github.com/Mangulomx/olimpiada
答案 0 :(得分:1)
在我看来,您没有在项目的任何位置加载users.php路由文件。如果未加载,则错误是正确的,因为它根据加载的路由不知道该路由。您可能希望将../routes/users.php添加到public / index.php。