smorken/tenancy
Composer 安装命令:
composer require smorken/tenancy
包简介
Opinionated stancl tenancy helper
README 文档
README
Uses stancl/tenancy
Install tenancy config and tenant migrations directory
$ php artisan tenancy:installer
Migrating/seeding
Central/Landlord
$ php artisan migrate [--seed]
Tenants
stancl/tenancy console commands
Edit config/tenancy.php migration_parameters and seeder_parameters
$ php artisan tenants:migrate [--tenants=TENANT_ID]
$ php artisan tenants:seed [--tenants=TENANT_ID]
$ php artisan tenants:run role:set --argument="user_id=12345"
Splitting routes/verifying a tenant early
You can use a Preloader to bring back the tenant without initializing tenancy.
In the example below, the DomainPreloader is used in conjunction with the
InitializeTenancyByDomain middleware (to actually initialize tenancy).
app/Providers/RouteServiceProvider.php
public function boot(): void
{
$this->configureRateLimiting();
$this->routes(function () {
$tenant = $this->preloadTenant();
if (!$tenant) {
Route::prefix('api')
->middleware('api')
->namespace($this->namespace)
->group(base_path('routes/api.php'));
Route::middleware('web')
->namespace($this->namespace)
->group(base_path('routes/web.php'));
} else {
Route::namespace($this->namespace)
->middleware([
'web',
InitializeTenancyByDomain::class,
PreventAccessFromCentralDomains::class,
])
->group(base_path('routes/tenant.php'));
}
});
}
protected function preloadTenant(): ?Tenant
{
if ($this->app->runningInConsole()) {
return null;
}
/** @var \Smorken\Tenancy\Contracts\Preloaders\Preloader $loader */
$loader = $this->app->make(DomainPreloader::class);
return $loader->load($this->app['request']);
}
smorken/tenancy 适用场景与选型建议
smorken/tenancy 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 168 次下载、GitHub Stars 达 0, 最近一次更新时间为 2022 年 10 月 11 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「laravel」 「multi-tenancy」 「stancl tenancy」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 smorken/tenancy 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 smorken/tenancy 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 smorken/tenancy 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Multi-tenancy handling for PHP apps.
Second-level tenancy scope (e.g. service area, region, location) for Filament panels — topnav dropdown filter that scopes Eloquent queries globally.
This package allows you to persists setting for Laravel projects.
Alfabank REST API integration
This bundle provides tools to build multi-tenant architecture for PHP applications.
Render user templates using the power of Twig
统计信息
- 总下载量: 168
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 16
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2022-10-11