PHPackages                             ronu/laravel-app-context - 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. [Authentication &amp; Authorization](/categories/authentication)
4. /
5. ronu/laravel-app-context

ActiveLibrary[Authentication &amp; Authorization](/categories/authentication)

ronu/laravel-app-context
========================

Multi-channel application context management for Laravel with JWT and API Key authentication

1.2.1(1mo ago)061[7 issues](https://github.com/charlietyn/laravel-app-context/issues)MITPHPPHP ^8.2

Since Jan 21Pushed 1mo agoCompare

[ Source](https://github.com/charlietyn/laravel-app-context)[ Packagist](https://packagist.org/packages/ronu/laravel-app-context)[ RSS](/packages/ronu-laravel-app-context/feed)WikiDiscussions main Synced today

READMEChangelogDependencies (8)Versions (44)Used By (0)

Laravel App Context
===================

[](#laravel-app-context)

[![Latest Version on Packagist](https://camo.githubusercontent.com/0aec9b3ef97efa535b42deadf9ac5158eb296f7bf6a318a11dfc66315b16a268/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f726f6e752f6c61726176656c2d6170702d636f6e746578742e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/ronu/laravel-app-context)[![Total Downloads](https://camo.githubusercontent.com/804d9973c76225f308107874b4970793b1c07c64ce9b32d4ddbb6a8f446ec3be/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f726f6e752f6c61726176656c2d6170702d636f6e746578742e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/ronu/laravel-app-context)[![License](https://camo.githubusercontent.com/206bd8e3531ed33f6388e372fce59c8c7704a6bb0b10f8a9594f73d6c3c74114/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f726f6e752f6c61726176656c2d6170702d636f6e746578742e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/ronu/laravel-app-context)

**Multi-channel application context management for Laravel** (JWT + API key auth) with channel detection, context-aware rate limiting, and audit logging.

- **Documentation:** [documentation/index.md](documentation/index.md)

Requirements
------------

[](#requirements)

- PHP 8.2+
- Laravel 11.x or 12.x
- `php-open-source-saver/jwt-auth` 2.x

Installation
------------

[](#installation)

```
composer require ronu/laravel-app-context
```

Publish config:

```
php artisan vendor:publish --tag=app-context-config
```

Quickstart
----------

[](#quickstart)

1. Configure a channel in `config/app-context.php`:

```
'channels' => [
    'site' => [
        'subdomains' => ['www', null],
        'path_prefixes' => ['/site'],
        'auth_mode' => 'jwt_or_anonymous',
        'jwt_audience' => 'site',
        'allowed_scopes' => ['site:*', 'catalog:browse'],
        'public_scopes' => ['catalog:browse'],
        'rate_limit_profile' => 'site',
        'tenant_mode' => 'single',
        'features' => [
            'allow_anonymous' => true,
        ],
    ],
],
```

2. Apply the middleware group:

```
use Illuminate\Support\Facades\Route;
use Ronu\AppContext\Facades\AppContext;

Route::middleware(['app-context'])->group(function () {
    Route::get('/site/profile', function () {
        return response()->json([
            'channel' => AppContext::getAppId(),
            'auth_mode' => AppContext::getAuthMode(),
            'scopes' => AppContext::getScopes(),
        ]);
    });
});
```

Configuration
-------------

[](#configuration)

- Config lives in `config/app-context.php` (publish tag: `app-context-config`).
- Environment variable reference: [documentation/02-configuration/01-env-vars.md](documentation/02-configuration/01-env-vars.md)
- Full config reference: [documentation/02-configuration/00-configuration-reference.md](documentation/02-configuration/00-configuration-reference.md)

Common scenarios
----------------

[](#common-scenarios)

### 1) Mobile app with JWT scopes

[](#1-mobile-app-with-jwt-scopes)

```
Route::middleware(['app-context', 'app.requires:mobile:orders:read'])->group(function () {
    Route::get('/mobile/orders', fn () => ['ok' => true]);
});
```

### 2) Partner API with API keys

[](#2-partner-api-with-api-keys)

```
Route::middleware(['app-context', 'app.requires:partner:orders:read'])->group(function () {
    Route::get('/partner/orders', fn () => ['ok' => true]);
});
```

### 3) Admin dashboard (subdomain detection)

[](#3-admin-dashboard-subdomain-detection)

```
Route::middleware(['app-context', 'app.scope:admin:*'])->group(function () {
    Route::get('/api/admin/metrics', fn () => ['ok' => true]);
});
```

More scenarios: [documentation/03-usage/02-scenarios.md](documentation/03-usage/02-scenarios.md)

Edge scenarios
--------------

[](#edge-scenarios)

Common edge cases include config caching, queue workers, burst traffic, tenant mismatches, and JWT blacklist races.

See: [documentation/03-usage/03-edge-and-extreme-scenarios.md](documentation/03-usage/03-edge-and-extreme-scenarios.md)

API reference
-------------

[](#api-reference)

- [Public API](documentation/04-reference/00-public-api.md)
- [Middleware](documentation/04-reference/02-middleware.md)
- [Artisan commands](documentation/04-reference/01-artisan-commands.md)

Troubleshooting
---------------

[](#troubleshooting)

Start here: [documentation/05-quality/02-troubleshooting.md](documentation/05-quality/02-troubleshooting.md)

Contributing / Security
-----------------------

[](#contributing--security)

- [Security](documentation/05-quality/00-security.md)
- [Testing](documentation/05-quality/01-testing.md)

---

**Start here:** [documentation/index.md](documentation/index.md)

###  Health Score

45

—

FairBetter than 93% of packages

Maintenance92

Actively maintained with recent releases

Popularity11

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity59

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 91.9% 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 ~1 days

Total

20

Last Release

43d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/0f59437a00cb4187df5eeb376f1c72053def2a2b16227a1e70d0c48ab2c99a4e?d=identicon)[charlietyn](/maintainers/charlietyn)

---

Top Contributors

[![charlietyn](https://avatars.githubusercontent.com/u/10063918?v=4)](https://github.com/charlietyn "charlietyn (79 commits)")[![claude](https://avatars.githubusercontent.com/u/81847?v=4)](https://github.com/claude "claude (7 commits)")

---

Tags

jwtmiddlewarelaravelsecurityAuthenticationContextmulti-tenantapi-key

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/ronu-laravel-app-context/health.svg)

```
[![Health](https://phpackages.com/badges/ronu-laravel-app-context/health.svg)](https://phpackages.com/packages/ronu-laravel-app-context)
```

###  Alternatives

[hosseinhezami/laravel-permission-manager

Advanced permission manager for Laravel.

393.1k](/packages/hosseinhezami-laravel-permission-manager)

PHPackages © 2026

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