简体   繁体   English

Mezzio => 服务未注册

[英]Mezzio => Service not registered

I have created a new module named ModuleA, which contains a middleware named MiddlewareA.我创建了一个名为 ModuleA 的新模块,其中包含一个名为 MiddlewareA 的中间件。 I also have created a route (eg "login") which has MiddlewareA in its pipeline.我还创建了一个路由(例如“登录”),它的管道中有 MiddlewareA。

When I send a request to the path "login", get response which states that当我向路径“登录”发送请求时,得到响应,指出

Service MiddlewareA not registered

What is the solution to this problem?这个问题的解决方案是什么?

Please check if you have added the new module to the composer.json file of the project, like:请检查您是否已将新模块添加到项目的 composer.json 文件中,例如:

"autoload": {
    "psr-4": {
        "App\\": "src/App/src/",
        "ModuleA\\": "src/ModuleA/src/"
    }
},

After that please run this command on the project route:之后,请在项目路径上运行此命令:

composer dump-autoload

Please proceed these steps every time you create a new Module.每次创建新模块时,请继续执行这些步骤。

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM