我通过composer create-project symfony/skeleton:“6.3.*”my_project创建symfony项目,然后创建一个名为shared adding composer.json的库。其想法是让我的库为my_project提供公共代码
composer.json my_project
{
"type": "project",
"license": "proprietary",
"minimum-stability": "stable",
"prefer-stable": true,
"require": {
"shared/library": "dev-main" <- my library
},
"repositories": [
{
"type": "path",
"url": "../../Shared/"
}
],
}
字符串
composer.json共享库
{
"name": "shared/library",
"description": "Shared code between microservices",
"autoload": {
"psr-4": {
"Shared\\": "/"
}
}
}
型
现在使用公共库注册类从库到服务。yaml在本例中注册类用于消息总线
services.yaml
Shared\:
resource: "../../../Shared/"
_instanceof:
Shared\Application\Command\CommandHandlerInterface:
public: true
tags:
- { name: messenger.message_handler, bus: messenger.bus.command }
Shared\Application\Query\QueryHandlerInterface:
public: true
tags:
- { name: messenger.message_handler, bus: messenger.bus.query }
型
现在我得到了错误:
**#message: "Compile Error: Cannot declare class Composer\Autoload\ClassLoader, because the name is already in use"**
型
1条答案
按热度按时间8iwquhpp1#
你不需要资源加载器。
字符串
InstanceOf就足够了。我一直用这个。