PHPackages                             equidna/bee-hive - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Framework](/categories/framework)
4. /
5. equidna/bee-hive

ActiveLibrary[Framework](/categories/framework)

equidna/bee-hive
================

Reusable multi-tenant foundation for Laravel applications.

3.0.0(2mo ago)01.0k↓86.2%3proprietaryPHPPHP ^8.2CI failing

Since Apr 20Pushed 2mo agoCompare

[ Source](https://github.com/EquidnaMX/bee-hive)[ Packagist](https://packagist.org/packages/equidna/bee-hive)[ RSS](/packages/equidna-bee-hive/feed)WikiDiscussions main Synced 1w ago

READMEChangelog (3)Dependencies (7)Versions (5)Used By (3)

equidna/bee-hive
================

[](#equidnabee-hive)

Reusable multi-tenant foundation package for Laravel projects.

What It Includes
----------------

[](#what-it-includes)

- Tenant resolver contract
- Tenant context container
- Eloquent global scope for tenant filtering
- BelongsToTenant trait with automatic tenant key fill
- Service provider with publishable config

Architecture
------------

[](#architecture)

 ```
flowchart LR
	A[Laravel Container] --> B[BeeHiveServiceProvider]
	B --> C[TenantResolverInterface]
	C --> D[Configured Resolver]
	D --> E[TenantContext]

	E --> F[TenantScope]
	E --> G[BelongsToTenant Trait]

	F --> H[Query Filtering by tenant key]
	G --> I[Auto-fill tenant key on create]

	F --> J{Tenant ID resolved?}
	J -->|Yes| H
	J -->|No| L[BeeHiveException]
	L --> M[RFC 7807 Problem Details Response]
```

      Loading Flow summary:

1. The service provider binds the configured tenant resolver and initializes `TenantContext`.
2. `TenantScope` reads the tenant from context to enforce query-level isolation.
3. `BelongsToTenant` uses the same context to auto-assign tenant key values on model creation.
4. Missing tenant resolution always throws `BeeHiveException` with an RFC 7807 `problem_details` JSON response.

Error Response
--------------

[](#error-response)

When tenant resolution fails, `BeeHiveException` returns an RFC 7807 `problem_details` JSON response:

```
{
  "type": "urn:beehive:error:tenant_not_resolved",
  "title": "BeeHive Exception",
  "status": 422,
  "detail": "BeeHive tenant was not resolved.",
  "code": "tenant_not_resolved"
}
```

Config keys (in `config/bee-hive.php`):

- `errors.status`: HTTP status code for tenant resolution errors (default: `422`)
- `logging.enabled`: enable package log emission (default: `true`)
- `logging.level`: package log level (`warning` by default)
- `logging.sample_rate`: sampling ratio between `0` and `1` (default: `1.0`)

Environment variables:

- `BEE_HIVE_ERROR_STATUS`
- `BEE_HIVE_LOGGING_ENABLED`
- `BEE_HIVE_LOG_LEVEL`
- `BEE_HIVE_LOG_SAMPLE_RATE`

Quality Checks
--------------

[](#quality-checks)

Run repository quality checks locally:

- `composer validate --no-check-publish`
- `composer audit --no-interaction`
- `./vendor/bin/phpcs --standard=ruleset.xml src config tests`
- `./vendor/bin/phpstan analyse --memory-limit=512M`
- `./vendor/bin/phpunit`

CI additionally runs workflow linting (`actionlint`) to prevent invalid GitHub workflow syntax from reaching main.

Or run the aggregated command:

- `composer qa`
- `composer qa:fast` for validate + lint + tests without audit/static analysis

Security Behavior
-----------------

[](#security-behavior)

- Tenant-scoped reads and writes require a resolved tenant.
- Missing tenant resolution throws `BeeHiveException`.
- Model creation always applies the resolved tenant value, even if a different tenant value is provided in input.

Observability
-------------

[](#observability)

BeeHive logs warning events when:

- A tenant-scoped query runs without a resolved tenant.
- A tenant-scoped model is created without a resolved tenant.
- A model create payload includes a tenant value different from the resolved context.

Each event includes a stable `event_code` field for alerting and dashboard rules.

Sampling behavior (`logging.sample_rate`) is tested deterministically in the test suite to avoid flaky observability checks.

The emitted package level still passes through the global Laravel logging configuration (channels, handlers, and minimum levels).

### Event Catalog

[](#event-catalog)

event\_codeTriggerSuggested severityContext fields`BEEHIVE_TENANT_UNRESOLVED_QUERY`A tenant-scoped query runs without a resolved tenantwarning`model`, `tenant_key`, `resolver``BEEHIVE_TENANT_UNRESOLVED_CREATE`A tenant-scoped model create operation runs without a resolved tenantwarning`model`, `tenant_key``BEEHIVE_TENANT_SPOOF_ATTEMPT`Input tenant differs from resolved tenant during createwarning`model`, `tenant_key`, `incoming_tenant_id`, `resolved_tenant_id`Suggested alerting thresholds:

- Alert immediately on any sustained `BEEHIVE_TENANT_UNRESOLVED_QUERY` volume in production.
- Investigate any `BEEHIVE_TENANT_SPOOF_ATTEMPT` event as potentially malicious client behavior.

###  Health Score

43

—

FairBetter than 89% of packages

Maintenance83

Actively maintained with recent releases

Popularity19

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity49

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~4 days

Total

3

Last Release

87d ago

Major Versions

1.0.0 → 2.0.02026-04-25

2.0.0 → 3.0.02026-04-28

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/984800?v=4)[gruelas](/maintainers/gruelas)[@gruelas](https://github.com/gruelas)

---

Top Contributors

[![gruelasjr](https://avatars.githubusercontent.com/u/40619710?v=4)](https://github.com/gruelasjr "gruelasjr (10 commits)")

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StylePHP\_CodeSniffer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/equidna-bee-hive/health.svg)

```
[![Health](https://phpackages.com/badges/equidna-bee-hive/health.svg)](https://phpackages.com/packages/equidna-bee-hive)
```

###  Alternatives

[psalm/plugin-laravel

Psalm plugin for Laravel

3345.3M347](/packages/psalm-plugin-laravel)[mike-bronner/laravel-model-caching

Automatic caching for Eloquent models.

2.4k96.5k1](/packages/mike-bronner-laravel-model-caching)[api-platform/laravel

API Platform support for Laravel

58174.6k17](/packages/api-platform-laravel)[pressbooks/pressbooks

Pressbooks is an open source book publishing tool built on a WordPress multisite platform. Pressbooks outputs books in multiple formats, including PDF, EPUB, web, and a variety of XML flavours, using a theming/templating system, driven by CSS.

45444.2k1](/packages/pressbooks-pressbooks)[fleetbase/core-api

Core Framework and Resources for Fleetbase API

1235.9k21](/packages/fleetbase-core-api)[aedart/athenaeum

Athenaeum is a mono repository; a collection of various PHP packages

255.2k](/packages/aedart-athenaeum)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
