简体   繁体   English

如何解决这个错误“App\Controller\CoreController”没有设置容器,你是不是忘了将它定义为服务订阅者?

[英]how to fix this error "App\Controller\CoreController" has no container set, did you forget to define it as a service subscriber?

i was deconnected any times at my application so i've want fix the problem but i've this error ans my folders / services was correctly configured.我在我的应用程序中任何时候都断开连接,所以我想解决这个问题,但我有这个错误,我的文件夹/服务配置正确。 I would like to know if anyone has ever encountered this problem and if so how to fix it.我想知道是否有人遇到过这个问题,如果遇到过如何解决。

Services.yaml服务.yaml

# This file is the entry point to configure your own services.
# Files in the packages/ subdirectory configure your dependencies.

# Put parameters here that don't need to change on each machine where the app is deployed
# https://symfony.com/doc/current/best_practices.html#use-parameters-for-application-configuration
parameters:

services:
    # default configuration for services in *this* file
    _defaults:
        autowire: true      # Automatically injects dependencies in your services.
        autoconfigure: true # Automatically registers your services as commands, event subscribers, etc.

    # makes classes in src/ available to be used as services
    # this creates a service per class whose id is the fully-qualified class name
    App\:
        resource: '../src/'
        exclude:
            - '../src/DependencyInjection/'
            - '../src/Entity/'
            - '../src/Kernel.php'

    App\Controller\:
        resource: '../src/Controller'
        tags: ['controller.service_arguments']

    # add more service definitions when explicit configuration is needed
    # please note that last definitions always *replace* previous ones

    

CoreController核心控制器

    
namespace App\Controller;

use App\Entity\Intervention;
use Doctrine\ORM\Mapping\Id;
use Doctrine\DBAL\Schema\Index;
use App\Repository\OperateurRepository;
use Doctrine\Persistence\ManagerRegistry;
use App\Repository\InterventionRepository;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;


class CoreController extends AbstractController
{```

I've fix with我已经修复了


        calls:
        - [setContainer, ["@service_container"]]

in services.yaml在服务.yaml

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 controller 没有设置容器,是不是忘记定义为服务订阅者了 - Controller has no container set, did you forget to define it as a service subscriber controller 无法从容器中获取,因为它是私有的。 您是否忘记使用“controller.service_arguments”标记服务? - controller cannot be fetched from the container because it is private. Did you forget to tag the service with "controller.service_arguments"? 仅在使用静态方法时,如何解决Symfony中的“您忘记了“使用”语句[…]”的问题? - How to fix 'Did you forget a “use” statement […]' in Symfony only when using static methods? 您是否忘记了Service上另一个名称空间的“使用”语句? - Did you forget a “use” statement for another namespace on Service? 通过“container.service_subscriber”向控制器添加服务未按预期工作 - Adding services to a Controller through "container.service_subscriber" not working as expected 控制器必须返回响应(给出空值)。 您是否忘记在控制器中的某处添加 return 语句? 请 - The controller must return a response (null given). Did you forget to add a return statement somewhere in your controller? please controller 更改目录结构后没有容器设置错误 - controller has no container set error after chaning directory structure 带有 MicroKernelTrait 的 Symfony 5 微应用程序抛出错误“控制器没有设置容器” - Symfony 5 micro application with MicroKernelTrait throws error "controller has no container set" Laraver:当我在另一个控制器中调用一个控制器时,总是会遇到此错误:“找不到类'CoreController'” - Laraver: I'm always getting this error when I call a controller in another controller: “Class 'CoreController' not found” 您是否忘记了另一个名称空间的“使用”语句? - Did you forget a “use” statement for another namespace?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM