Download the PHP package sinceleo/hf-tenant without Composer
On this page you can find all versions of the php package sinceleo/hf-tenant. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Please rate this library. Is it a good library?
Informations about the package hf-tenant
Tenancy for Hyperf
介绍
一个轻量级租户系统,支持多租户,支持跨租户请求,支持跨租户队列,支持跨租户数据库,支持跨租户缓存,支持跨租户日志,支持跨租户事件,支持跨租户路由,支持跨租户服务,支持跨租户配置,支持跨租户中间件,支持跨租户控制器,支持跨租户模型,支持跨租户服务提供者,
基于:Laravel Tenancy为灵感开发的一套简易版租户插件,让Hyperf也可以支持多租户,像Laravel Tenancy一样开发单租户业务一样,通过组件实现多租户的模式,做到真正的数据隔离 实现方式:通过中间件实现租户编号的获取,并设置到协程上下文中,通过重写数据库连接,在请求数据库时,自动切换到对应租户的数据库连接
安装
配置部分
生成配置文件
修改缓存配置
-
cache.php修改为如下配置
-
databases.php 增加如下配置
-
redis.php 增加如下配置
- 配置文件tenancy.php 可选配置(可根据实际情况自行修改前缀等)
初始化
执行构建租户管理迁移文件 php bin/hyperf.php tenants:init
- 注:必须配置好上述databases中的central数据库配置,手动创建好数据库
- 租户编号请在central中央库中进行维护,通过域名识别租户编号需要在central库中的tenant表与domain_tenants表中存在相应配置
使用说明
获取租户编号的方式有两种:
一、前端接口请求时在header中携带租户编号,如: X-TENANT-ID:xxxx
二、在请求时通过域名获取租户编号,如:http://baidu.domain.com 内部将通过域名获取租户编号
租户操作
数据迁移
- 使用 tenants:migrate-gen 进行创建生成迁移文件, 或通过其他方式创建迁移文件,但需更改迁移文件继承类为TenantMigration
- --tenants 为可选参数,默认不传递则所有租户执行此迁移,传递租户编号则只执行此租户
- php bin/hyperf.php tenants的迁移命令都继承于hyperf自身,所以框架自身支持的path,database等参数都支持使用
队列使用
发送队列
All versions of hf-tenant with dependencies
PHP Build Version
Package Version
Requires
php Version
>=8.2
hyperf/engine Version ^2.8
hyperf/coroutine Version ^3.1
hyperf/logger Version ^3.1
hyperf/http-server Version ^3.1
hyperf/di Version ^3.1
hyperf/cache Version ^3.1
guzzlehttp/guzzle Version ^7.7
hyperf/paginator Version ^3.1
hyperf/resource Version ^3.1
hyperf/framework Version ^3.1
hyperf/database Version ^3.1
hyperf/db-connection Version ^3.1
hyperf/config Version ^3.1
hyperf/redis Version ^3.1
hyperf/model-cache Version ^3.1
hyperf/amqp Version ^3.1
hyperf/async-queue Version ^3.1
hyperf/engine Version ^2.8
hyperf/coroutine Version ^3.1
hyperf/logger Version ^3.1
hyperf/http-server Version ^3.1
hyperf/di Version ^3.1
hyperf/cache Version ^3.1
guzzlehttp/guzzle Version ^7.7
hyperf/paginator Version ^3.1
hyperf/resource Version ^3.1
hyperf/framework Version ^3.1
hyperf/database Version ^3.1
hyperf/db-connection Version ^3.1
hyperf/config Version ^3.1
hyperf/redis Version ^3.1
hyperf/model-cache Version ^3.1
hyperf/amqp Version ^3.1
hyperf/async-queue Version ^3.1
The package sinceleo/hf-tenant contains the following files
Loading the files please wait ....