找不到Symfony 4批注页面

时间:2018-09-18 20:51:34

标签: php .htaccess symfony symfony4 symfony-routing

我尝试在道路上行驶,但是当我在这条道路上行驶时,页面404出现。这是我的代码:

我的控制器:

    <?php

namespace App\Controller;

use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\Routing\Annotation\Route;

class GamesController extends AbstractController
{
    /**
     * @Route("/{game}/{region}", name="games")
     */
    public function gamesAction($game, $region)
    {
        return $this->render('games/index.html.twig', [
            'game' => 'toto',
            'region' => 'titi',
            'statut_serveur' => 'ok'
        ]);
    }
}

模板链接:

<div class="col-12 col-md-2" id="wow">
                <div class="choices">
                    <div class="front">
                        <img class="img-fluid" src="{{ asset('img/M7G2U62LWFRW1506441174974.jpg') }}" alt="">
                    </div>
                    <div class="hover">
                        <div>
                            <a id="usa-realm" href="{{ path('games', {'game':'wow', 'region':'EU'}) }}"><img class="img-fluid" src="{{ asset('img/usa-top.png') }}" alt=""></a>
                        </div>
                        <div>
                            <a id="eur-realms" href="{{ path('games', {'game':'wow', 'region':'US'}) }}"><img class="img-fluid" src="{{ asset('img/eur-bot.png') }}" alt=""></a>
                        </div>
                    </div>
                </div>
            </div>

模板控制器:

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

{% block title %}{{ game }}-{{ region }}{% endblock %}

{% block body %}
    <table>
        <thead>
        <tr>
            <th scope="col">Nom</th>
            <th scope="col">Type</th>
            <th scope="col">Locale</th>
            <th scope="col">Statut</th>
        </tr>
        </thead>
        <tbody>
    {% for statut in statut_serveur.realms %}
        <tr>
            <th>{{ statut.name }}</th>
            <th>{{ statut.type }}</th>
            <th>{{ statut.locale }}</th>
            <th>{{ statut.status }}</th>
        </tr>
    {% endfor %}
    </table>
{% endblock %}

注释包已正确安装,但没有任何内容使找不到页面出现。谢谢您的帮助。

htaccess中的此解决方案:

<IfModule mod_rewrite.c>
Options -MultiViews
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php [QSA,L]
</IfModule>

0 个答案:

没有答案