{"id":41794791,"url":"https://github.com/anikrahman0/laravel-hive","last_synced_at":"2026-01-25T05:11:17.614Z","repository":{"id":329622399,"uuid":"1120229420","full_name":"anikrahman0/laravel-hive","owner":"anikrahman0","description":"A lightweight, production-ready multi-tenant infrastructure package for Laravel 12 applications. Laravel Hive focuses on tenant resolution, isolation, and developer freedom — without forcing authentication, UI, or hosting decisions.","archived":false,"fork":false,"pushed_at":"2025-12-20T19:23:36.000Z","size":18,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-12-22T19:43:05.929Z","etag":null,"topics":["composer-package","database-per-tenant","laravel","laravel-12","laravel-hive","laravel-infrastructure","laravel-package","laravel-saas","laravel-tenancy","lightweight-developer-tools","multi-database-multi-tenancy","multi-tenancy","multi-tenant-tenancy","php","production-ready","saas","tenant-isolation","tenant-resolution"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/anikrahman0.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-12-20T18:54:50.000Z","updated_at":"2025-12-20T19:43:18.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/anikrahman0/laravel-hive","commit_stats":null,"previous_names":["anikrahman0/laravel-hive"],"tags_count":null,"template":false,"template_full_name":null,"purl":"pkg:github/anikrahman0/laravel-hive","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/anikrahman0%2Flaravel-hive","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/anikrahman0%2Flaravel-hive/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/anikrahman0%2Flaravel-hive/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/anikrahman0%2Flaravel-hive/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/anikrahman0","download_url":"https://codeload.github.com/anikrahman0/laravel-hive/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/anikrahman0%2Flaravel-hive/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28744421,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-25T02:46:29.005Z","status":"ssl_error","status_checked_at":"2026-01-25T02:44:29.968Z","response_time":113,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["composer-package","database-per-tenant","laravel","laravel-12","laravel-hive","laravel-infrastructure","laravel-package","laravel-saas","laravel-tenancy","lightweight-developer-tools","multi-database-multi-tenancy","multi-tenancy","multi-tenant-tenancy","php","production-ready","saas","tenant-isolation","tenant-resolution"],"created_at":"2026-01-25T05:11:17.515Z","updated_at":"2026-01-25T05:11:17.597Z","avatar_url":"https://github.com/anikrahman0.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Laravel Hive 🐝\n\u003cimg src=\"https://i.imgur.com/FMc1luj.png\"\u003e\n\u003c!-- [![Packagist Version](https://img.shields.io/packagist/v/anikrahman/laravel-hive.svg)](https://packagist.org/packages/anikrahman/laravel-hive)\n[![License](https://img.shields.io/packagist/l/anikrahman/laravel-hive.svg)](https://github.com/anikrahman0/laravel-hive/blob/main/LICENSE) --\u003e\n\u003c!-- [![PHP Version](https://img.shields.io/packagist/php-v/anikrahman/laravel-hive.svg)](https://www.php.net/) --\u003e\n\nA lightweight, production-ready **multi-tenant infrastructure package** for Laravel 12 applications. Laravel Hive focuses on **tenant resolution**, **isolation**, and **developer freedom** — without forcing authentication, UI, or hosting decisions.\n\n---\n\n## ✨ Features\n\n- Subdomain-based tenant resolution (`acme.example.com`)  \n- Optional custom domain support (`tenantdomain.com`)  \n- Automatic tenant context binding  \n- Tenant suspension \u0026 activation  \n- Shared database or DB-per-tenant support  \n- Automatic tenant scoping for Eloquent models  \n- Artisan commands for tenant management  \n- Fully compatible with Laravel 12\n\n---\n\n## 📦 Installation \u0026 Configuration\n\nFollow these steps to install, configure, and start using Laravel Hive:\n\n```bash\n# 1. Require the package via Composer\ncomposer require anikrahman/laravel-hive\n\n# 2. Publish configuration\nphp artisan vendor:publish --tag=hive-config\n\n# 3. Publish migrations\nphp artisan vendor:publish --tag=hive-migrations\n\n# 4. Run migrations\nphp artisan migrate\n```\n\n---\n\n## 🏁 User Guide (Usage Instructions)\n\nAfter installing and configuring Laravel Hive, follow these steps:\n\n### Step 1: Apply middleware to routes\n\nAdd the tenant middleware to any routes that need tenant-specific behavior:\n\n```php\nRoute::middleware('hive.tenant')-\u003egroup(function () {\n    Route::get('/dashboard', function () {\n        return Tenant::current()-\u003ename;\n    });\n});\n```\n\n### Step 2: Make models tenant-aware\n\nUse the `BelongsToTenant` trait for any model that belongs to a tenant:\n\n```php\nuse AnikRahman\\Hive\\Traits\\BelongsToTenant;\n\nclass Post extends Model\n{\n    use BelongsToTenant;\n}\n```\n\nAll queries on these models are automatically scoped to the current tenant.\n\n### Step 3: Create a tenant\n\nUse the Artisan command:\n\n```bash\nphp artisan tenant:create \"Acme Corp\" acme --plan=pro\n```\n\n- **\"Acme Corp\"** → tenant name\n- **acme** → tenant subdomain  \n- **--plan=pro** → optional plan/feature flag\n\nThis creates a tenant entry in the database.\n\n### Step 4: Run migrations for a tenant (DB-per-tenant only)\n\n```bash\nphp artisan tenant:migrate acme\n```\n\nOptional fresh reset:\n\n```bash\nphp artisan tenant:migrate acme --fresh\n```\n\n### Step 5: Suspend or activate a tenant\n\n```bash\nphp artisan tenant:status acme inactive\nphp artisan tenant:status acme active\n```\n\nSuspended tenants cannot access tenant-specific routes or data.\n\n### Step 6: Access the current tenant in code\n\nAnywhere in your Laravel application:\n\n```php\n$tenant = Tenant::current();\n$tenantId = Tenant::id();\n$plan = Tenant::plan();\n```\n\nThis allows you to implement tenant-specific logic, feature toggles, or queries.\n\n---\n\n## 🔧 Requirements\n\n- PHP 8.1 or higher\n- Laravel 12.0 or higher \n\n## 🎯 Basic Usage\n\n### 1. Define Tenant-Scoped Models\n\n```php\nnamespace App\\Models;\n\nuse Illuminate\\Database\\Eloquent\\Model;\nuse AnikRahman\\Hive\\Traits\\BelongsToTenant;\n\nclass Product extends Model\n{\n    use BelongsToTenant;\n\n    protected $fillable = ['name', 'price'];\n}\n```\n\n### 2. Create and Manage Tenants\n\n```bash\n# Create a new tenant\nphp artisan tenant:create \"My Company\" mycompany --plan=pro\n\n# List all tenants\nphp artisan tenant:list\n\n# Suspend a tenant\nphp artisan tenant:suspend mycompany\n\n# Activate a tenant\nphp artisan tenant:activate mycompany\n```\n\n### 3. Access Tenant Context\n\n```php\n// In controllers, services, or anywhere\n$currentTenant = Tenant::current();\n\n// Get tenant-specific data\n$products = Product::where('tenant_id', Tenant::id())-\u003eget();\n\n// Or let the trait handle it automatically\n$products = Product::all(); // Auto-scoped to current tenant\n```\n\n---\n\n## 🗂️ Database Strategies\n\nLaravel Hive supports multiple database strategies:\n\n### Shared Database (Default)\nAll tenants share the same database with a `tenant_id` column.\n\n### Database Per Tenant\nEach tenant gets its own database. Configure in `config/hive.php`:\n\n```php\n'database' =\u003e [\n    'strategy' =\u003e 'database_per_tenant',\n    'prefix' =\u003e 'tenant_',\n],\n```\n\n---\n\n## 🌐 Domain Configuration\n\nConfigure tenant domains in `.env`:\n\n```env\nAPP_DOMAIN=example.com\nTENANT_SUBDOMAIN_ENABLED=true\nTENANT_CUSTOM_DOMAIN_ENABLED=false\n```\n\n---\n\n## 🐛 Issues \u0026 Support\n\nFound a bug or need help? [Open an issue](https://github.com/anikrahman0/laravel-hive/issues)\n\n---\n\n## 📜 License\n\nThe MIT License (MIT). Please see [License File](LICENSE.md) for more information.\n\n---\n\n## 🙏 Credits\n\n**Name:** Md Anik Rahman  \n**Email:** anikrahman a7604366@gmail.com\n\n---\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fanikrahman0%2Flaravel-hive","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fanikrahman0%2Flaravel-hive","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fanikrahman0%2Flaravel-hive/lists"}