[英]Why I have "Not found" /admin in symfony easyAdminBundle 4 (php)
I can't open /admin page after installing easyAdminBundle in symfony app.在 symfony 应用程序中安装 easyAdminBundle 后,我无法打开 /admin 页面。
I do: symfony composer req "admin:^4"
then symfony console make:admin:dashboard
我这样做:
symfony composer req "admin:^4"
然后symfony console make:admin:dashboard
This line generate this code.此行生成此代码。
<?php
namespace App\Controller\Admin;
use EasyCorp\Bundle\EasyAdminBundle\Config\Dashboard;
use EasyCorp\Bundle\EasyAdminBundle\Config\MenuItem;
use EasyCorp\Bundle\EasyAdminBundle\Controller\AbstractDashboardController;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;
class DashboardController extends AbstractDashboardController
{
#[Route('/admin', name: 'admin')]
public function index(): Response
{
return parent::index();
// Option 1. You can make your dashboard redirect to some common page of your backend
//
// $adminUrlGenerator = $this->container->get(AdminUrlGenerator::class);
// return $this->redirect($adminUrlGenerator->setController(OneOfYourCrudController::class)->generateUrl());
// Option 2. You can make your dashboard redirect to different pages depending on the user
//
// if ('jane' === $this->getUser()->getUsername()) {
// return $this->redirect('...');
// }
// Option 3. You can render some custom template to display a proper dashboard with widgets, etc.
// (tip: it's easier if your template extends from @EasyAdmin/page/content.html.twig)
//
// return $this->render('some/path/my-dashboard.html.twig');
}
public function configureDashboard(): Dashboard
{
return Dashboard::new()
->setTitle('Symfony App');
}
public function configureMenuItems(): iterable
{
yield MenuItem::linkToDashboard('Dashboard', 'fa fa-home');
// yield MenuItem::linkToCrud('The Label', 'fas fa-list', EntityClass::class);
}
}
But when I try to open /admin page I get this: "Not Found The requested URL was not found on this server."但是当我尝试打开 /admin 页面时,我得到这个:“未找到请求的 URL 在此服务器上未找到。”
This lines doesn't help:这行没有帮助:
symfony console cache:clear
symfony composer dump-autoload
rm -rf var/cache/*
I want to see the start page at easyAdminBundle like in symfony documentation.我想在 symfony 文档中看到 easyAdminBundle 的起始页。 Why I can't get this?
为什么我不能得到这个?
I just solved this by changing the route for DashboardController::index
from '/admin'
to '/admin/d'
then going to http://127.0.0.1:8000/admin/d
我只是通过将
DashboardController::index
的路由从'/admin'
更改为'/admin/d'
然后转到http://127.0.0.1:8000/admin/d
来解决这个问题
class DashboardController extends AbstractDashboardController
{
#[Route('/admin/d', name: 'admin')]
public function index(): Response
{
return parent::index();
}
/* ... */
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.