[英]Symfony page not found (Symfony 3)
I am new in Symfony and i am working on existing project.我是 Symfony 的新手,我正在处理现有项目。 I have created crud with doctrine:generate:crud
, but application returns me 404 page not found.我已经创建了 crud doctrine:generate:crud
,但应用程序返回我找不到 404 页面。 I was debugging it with debug:router
and router:match
and everything was okay.我正在使用debug:router
和router:match
调试它,一切正常。
Here is my controller这是我的控制器
<?php
namespace AppBundle\Controller\Backend;
use AppBundle\Controller\BackendController;
use AppBundle\Entity\CsobApiUsers;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Method;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
use Symfony\Component\HttpFoundation\Request;
/**
* CsobApiUsers controller.
*
* @Route("csobApiUsers")
*/
class CsobApiUsersController extends BackendController
{
/**
* Lists all csobApiUser entities.
*
* @Route("/", name="csobapiusers_index")
* @Method("GET")
*/
public function indexAction()
{
die(var_dump("x"));
$em = $this->getDoctrine()->getManager();
$csobApiUsers = $em->getRepository('AppBundle:CsobApiUsers')->findAll();
return $this->render('csobapiusers/index.html.twig', array(
'csobApiUsers' => $csobApiUsers,
));
}
Controller is as same as another controller that works correctly.控制器与另一个正常工作的控制器相同。
Here is my router:match这是我的路由器:匹配
php bin/console router:match /backend/csobApiUsers/
[OK] Route "csobapiusers_index" matches
+--------------+---------------------------------------------------------+
| Property | Value |
+--------------+---------------------------------------------------------+
| Route Name | csobapiusers_index |
| Path | /backend/csobApiUsers/ |
| Path Regex | #^/backend/csobApiUsers/$#s |
| Host | ANY |
| Host Regex | |
| Scheme | ANY |
| Method | GET |
| Requirements | NO CUSTOM |
| Class | Symfony\Component\Routing\Route |
| Defaults | _controller: AppBundle:Backend\CsobApiUsers:index |
| Options | compiler_class: Symfony\Component\Routing\RouteCompiler |
+--------------+---------------------------------------------------------+
Here is debug:router for my controller这是调试:我的控制器的路由器
csobapiusers_index GET ANY ANY /backend/csobApiUsers/
csobapiusers_new GET|POST ANY ANY /backend/csobApiUsers/new
csobapiusers_show GET ANY ANY /backend/csobApiUsers/{id}
csobapiusers_edit GET|POST ANY ANY /backend/csobApiUsers/{id}/edit
csobapiusers_delete DELETE ANY ANY /backend/csobApiUsers/{id}
I calling https://my-address.com/backend/csobApiUsers/我打电话给https://my-address.com/backend/csobApiUsers/
Does anybody know where can be problem?有谁知道哪里有问题? Thanks谢谢
我认为您在控制器路由注释中缺少斜线,请在此处查看https://symfony.com/blog/new-in-symfony-3-4-prefix-all-controller-route-names
@Route("/csobApiUsers")
您是否尝试将 indexAction() 改为 index() ?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.