带有 Symfony 的 Prestashop 模块找不到控制器
Prestashop module with Symfony cant find the controller
我正在使用 Symfony 在 Prestashop 中创建一个模块,但是当我尝试访问我的路由时,我收到此错误:
The controller for URI "/modules/youtuber/list" is not callable: Class "Myyoutubemc\Controller\YoutubeController"
下面是我的控制器
它位于:
/modules/myyotubemc/src/controllers/youtubeController.php
<?php
namespace Myyoutubemc\Controller;
use GuzzleHttp\Subscriber\Redirect;
use Myyoutubemc\Entity\YoutubeComment;
use Myyoutubemc\Forms\YoutubeType;
use PrestaShopBundle\Controller\Admin\FrameworkBundleAdminController;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
class YoutubeController extends FrameworkBundleAdminController
{
public function demoAction()
{
return new Response('Hello Youtubers');
// return $this->render('@Modules/your-module/templates/admin/demo.html.twig');
}
public function listAction()
{
$em = $this->getDoctrine()->getManager();
$data = $em->getRepository(YoutubeComment::class)->findAll();
return $this->render(
'@Modules/myyoutubemc/templates/admin/list.html.twig',
[
'data' => $data
]
);
}
下面是我的路线位于
my_module/config/routes.yml
youtube-list:
path: youtuber/list
methods: [GET]
defaults:
_controller: 'Myyoutubemc\Controller\YoutubeController::listAction'
请问如何解决?
下面是错误截图
您必须安装 composer 或直接转储自动加载 类。
我正在使用 Symfony 在 Prestashop 中创建一个模块,但是当我尝试访问我的路由时,我收到此错误:
The controller for URI "/modules/youtuber/list" is not callable: Class "Myyoutubemc\Controller\YoutubeController"
下面是我的控制器
它位于:
/modules/myyotubemc/src/controllers/youtubeController.php
<?php
namespace Myyoutubemc\Controller;
use GuzzleHttp\Subscriber\Redirect;
use Myyoutubemc\Entity\YoutubeComment;
use Myyoutubemc\Forms\YoutubeType;
use PrestaShopBundle\Controller\Admin\FrameworkBundleAdminController;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
class YoutubeController extends FrameworkBundleAdminController
{
public function demoAction()
{
return new Response('Hello Youtubers');
// return $this->render('@Modules/your-module/templates/admin/demo.html.twig');
}
public function listAction()
{
$em = $this->getDoctrine()->getManager();
$data = $em->getRepository(YoutubeComment::class)->findAll();
return $this->render(
'@Modules/myyoutubemc/templates/admin/list.html.twig',
[
'data' => $data
]
);
}
下面是我的路线位于
my_module/config/routes.yml
youtube-list:
path: youtuber/list
methods: [GET]
defaults:
_controller: 'Myyoutubemc\Controller\YoutubeController::listAction'
请问如何解决?
下面是错误截图
您必须安装 composer 或直接转储自动加载 类。