0
サーバーを起動してhttp://127.0.0.1:8000にアクセスしようとすると、エラーUnable to generate a URL for the named route "login" as such route does not exist.
が表示されます。 /ログインへ名前付きルート「ログイン」のURLを生成できません
直接アクセスができます:No route found for "GET /login"
これはsymfony3とし、FOSBUNDLEなしです! に基づいてsymfony3 cookbook traditional log form。
のsecurity.yml:
securityController.php:
// src/AppBundle/Controller/SecurityContoller.php
namespace AppBundle\Controller;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\HttpFoundation\Request;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
class SecurityController extends Controller
{
/**
* @Route("/login", name="login")
*/
public function loginAction(Request $request)
{
$authenticationUtils = $this->get('security.authentication_utils');
// login error, if there is one
$error = $authenticationUtils->getLastAuthenticationError();
// last username entered
$lastUsername = $authenticationUtils->getLastUsername();
return $this->render(
'security/login.html.twig',
array(
'last_username' => $lastUsername,
'error' => $error,
)
);
}
}
あなたのrouting.ymlファイルは次のようにどのように見えるんように見える必要が
:config.ymlファイルでは、ルーティングの一部を定義する必要がありますか? – Laoneo
デフォルトでは、注釈を使用していても、手動でrouting.ymlに追加する必要がありますか? – Diamonte
はい、ルーティングファイルを追加する必要があります。私は答えを掲示している、何が必要です。 – Laoneo