ece2 / common
v1.2.5
2023-08-28 02:26 UTC
Requires
- php: >=8.0
- hyperf/amqp: ~3.0.0
- hyperf/async-queue: ~3.0.0
- hyperf/circuit-breaker: ~3.0.0
- hyperf/config-center: ~3.0.0
- hyperf/config-nacos: ~3.0.0
- hyperf/constants: ~3.0.0
- hyperf/crontab: ~3.0.0
- hyperf/database: ~3.0.0
- hyperf/db-connection: ~3.0.0
- hyperf/filesystem: ~3.0.0
- hyperf/flysystem-oss: ^1.0
- hyperf/http-server: ~3.0.0
- hyperf/json-rpc: ~3.0.0
- hyperf/metric: ~3.0.0
- hyperf/model-cache: ~3.0.0
- hyperf/paginator: ~3.0.0
- hyperf/rate-limit: ~3.0.0
- hyperf/redis: ~3.0.0
- hyperf/retry: ~3.0.0
- hyperf/rpc: ~3.0.0
- hyperf/rpc-client: ~3.0.0
- hyperf/rpc-server: ~3.0.0
- hyperf/service-governance: ~3.0.0
- hyperf/service-governance-nacos: ~3.0.0
- hyperf/snowflake: ~3.0.0
- hyperf/tracer: ~3.0.0
- hyperf/validation: ~3.0.0
- hyperf/websocket-server: ~3.0.0
- lysice/hyperf-redis-lock: ^2.1
- phpoffice/phpspreadsheet: ^1.23
- phpoffice/phpword: ^1.1
- symfony/property-access: ^6.0
- symfony/var-dumper: ^6.0
- zoujingli/ip2region: ^1.0
Requires (Dev)
- friendsofphp/php-cs-fixer: ^3.0
- hyperf/devtool: ~3.0.0
- hyperf/ide-helper: ~3.0.0
- hyperf/testing: ~3.0.0
- hyperf/watcher: ~3.0.0
- mockery/mockery: ^1.0
- phpstan/phpstan: ^1.0
- swoole/ide-helper: ^5.0
Suggests
- ext-json: Required to use JSON.
- ext-openssl: Required to use HTTPS.
- ext-pdo: Required to use MySQL Client.
- ext-pdo_mysql: Required to use MySQL Client.
- ext-redis: Required to use Redis Client.
README
安装
composer require ece2/common -W --ignore-platform-reqs
初始化, 仅仅用在刚刚创建的 hyperf 项目, 不然会覆盖项目代码
php bin/hyperf.php vendor:publish ece2/common -f
如果本地调试公共组件的话, 可以在 composer.json 里加入一下代码, 以及 url 按照本地目录有对应的公共组件项目代码, 然后 composer update
"repositories": {
"ece2/common": {
"type": "path",
"url": "../common"
}
}
增加的 command
按照数据表生成对应 model service controller 文件
php bin/hyperf.php gen:code --with-comments --refresh-fillable {表名}
用户身份传递
- (Http 相关) 鉴权走的 src/Aspect/AuthAspect, 根据注解 Auth($guard) 对应的 AuthAspect 里的 AuthenticationInterface 对应实现来 check token
- (RPC 相关) src/Aspect/JsonRpcIdTransferAspect 注入 RPC 请求前, 把当前 Http 写入上下文的用户信息写入 RPC 上下文
- (RPC 相关) src/Middleware/JsonRpcIdTransferMiddleware 接收到 RPC 请求, 从 RPC 请求上下文获取用户信息