小编Anf*_*Fun的帖子

无法自动装配服务“App\Controller\MainController”:方法“__construct()”的参数“$session”

有我的主控制器:

<?php

namespace App\Controller;

use App\Entity\ShopCart;
use App\Entity\ShopItem;
use App\Repository\ShopItemRepository;
use Doctrine\ORM\EntityManagerInterface;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpFoundation\Session\Session;
use Symfony\Component\HttpFoundation\Session\SessionInterface;
use Symfony\Component\Routing\Annotation\Route;
use Symfony\Config\Framework\SessionConfig;
use Symfony\Component\HttpFoundation\RequestStack;

class MainController extends AbstractController
{

    private SessionInterface $session;

    /**
     * @param SessionInterface $session
     */
    public function __construct(SessionInterface $session)
    {

        $this->session = $session;
        $this->session->start();
    }


    public function debug($data)
    {
        echo '<pre>' . print_r($data) . '</pre>';
    }

    #[Route('shop/list', name: 'List')]
    public function shopList(EntityManagerInterface $entityManager, ShopItemRepository $shopItemRepository): Response
    {
        $result = $shopItemRepository->findAll();
        return $this->render('shop-list.html.twig', [
            'shoes' => …
Run Code Online (Sandbox Code Playgroud)

php mysql shopping-cart symfony web

0
推荐指数
1
解决办法
2200
查看次数

标签 统计

mysql ×1

php ×1

shopping-cart ×1

symfony ×1

web ×1