dougan1205 2018-09-27 13:49
浏览 75

Symfony 3.4 - 自动服务线在方法中不起作用

I'm relatively new to Symfony, and I'm having trouble some trouble. I'm trying to type hint a custom RequestValidator class in the method being called when the endpoint is called.

Using Symfony 3.4

However, I am getting the following error:

Controller "ApiBundle\Endpoints\Healthcheck\v1\Index::check()" requires that you provide a value for the "$request" argument. Either the argument is nullable and no null value has been provided, no default value has been provided or because there is a non optional argument after this one.

Here is my setup:

services.yml file

           autowire: true
           autoconfigure: true



path: /healthcheck
controller: ApiBundle\Endpoints\Healthcheck\v1\Index::check
defaults: { _format: json }
    - GET

And then - inside the Index class, I have the following:


namespace ApiBundle\Endpoints\Healthcheck\v1;

use ApiBundle\Responses\ApiResponse;

class Index extends ApiResponse

      public function check(HealthcheckRequest $request) {


When I do debug:autowiring I see my HealthcheckRequest in the list.

Further, when I do the same and try type-hint in the constructor of the Index class, it all works.

And finally, if I try and type hint the Symfony/HttpFoundation/Request, inside the check() method, it instantiates it correctly.

In summary:

Not working :

  • check(HealthcheckRequest $request)


  • __construct(HealtcheckRequest $request)
  • check(SymfonyRequest $request)

Am I doing something wrong? Any help is appreciated.

  • 写回答



      相关推荐 更多相似问题


      • ¥20 用socket实现ping遇到的问题
      • ¥15 综合的类,这个类里面里面又有构造方法,重载方法,有继承,有重写,有接口
      • ¥15 电脑重置失败无法开机也进不了修复模式,如何解决?
      • ¥100 px4飞控如何设置平飞模式下飞机固定的仰角
      • ¥15 关于#python#的问题:不可以使用max ,min ,exit ,break 的情况下找出哪一年份出生率最高,以及哪一年份出生率最低
      • ¥15 WPF中使用DoDragDrop程序会崩,"FatalExecutionEngineError"
      • ¥15 C语言 堆排序 数据结构
      • ¥15 ue如何做自然的物体边缘磨损效果材质
      • ¥15 我是在windows环境下通过IIS部署django项目,但是是这样怎么处理呢
      • ¥30 51单片机测量脉冲周期/频率并加以计算、显示