I am creating a module in Prestashop with Symfony but when I try to access my routes I get this error:
The controller for URI "/modules/youtuber/list" is not callable: Class "Myyoutubemc\Controller\YoutubeController"
Below is my controller
it's located in:
/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
]
);
}
below is my routes located at
my_module/config/routes.yml
youtube-list:
path: youtuber/list
methods: [GET]
defaults:
_controller: 'Myyoutubemc\Controller\YoutubeController::listAction'
How can I solve it Please ?.
Below is the error screenshot
CodePudding user response:
You have to install composer or just dump autoload classes.