PHPackages                             artificertech/filament-multi-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. [Admin Panels](/categories/admin)
4. /
5. artificertech/filament-multi-context

Abandoned → filament v3ArchivedLibrary[Admin Panels](/categories/admin)

artificertech/filament-multi-context
====================================

a package for adding multiple contexts to the filament admin panel

V2.1.2(3y ago)8621.4k↓20.6%10[3 PRs](https://github.com/artificertech/filament-multi-context/pulls)MITPHPPHP ^8.0

Since Apr 26Pushed 2y ago5 watchersCompare

[ Source](https://github.com/artificertech/filament-multi-context)[ Packagist](https://packagist.org/packages/artificertech/filament-multi-context)[ Docs](https://github.com/artificertech/filament-multi-context)[ RSS](/packages/artificertech-filament-multi-context/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (10)Dependencies (15)Versions (15)Used By (0)

A package for adding multiple contexts to the filament admin panel
==================================================================

[](#a-package-for-adding-multiple-contexts-to-the-filament-admin-panel)

[![Latest Version on Packagist](https://camo.githubusercontent.com/db9f483afd3e28f9f753384f68ef183e5bd4d307e0d589b8305a73bd313bff46/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f617274696669636572746563682f66696c616d656e742d6d756c74692d636f6e746578742e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/artificertech/filament-multi-context)[![GitHub Tests Action Status](https://camo.githubusercontent.com/4526a736ebdaa288b72c950f0930c61ec976ac1e38730403a7b540848b0d5939/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f776f726b666c6f772f7374617475732f617274696669636572746563682f66696c616d656e742d6d756c74692d636f6e746578742f72756e2d74657374733f6c6162656c3d7465737473)](https://github.com/artificertech/filament-multi-context/actions?query=workflow%3Arun-tests+branch%3Amain)[![GitHub Code Style Action Status](https://camo.githubusercontent.com/cb0d913da490d591c15c6d6539c7ae17d2549922e3ecccf12adf947111619736/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f776f726b666c6f772f7374617475732f617274696669636572746563682f66696c616d656e742d6d756c74692d636f6e746578742f436865636b253230262532306669782532307374796c696e673f6c6162656c3d636f64652532307374796c65)](https://github.com/artificertech/filament-multi-context/actions?query=workflow%3A%22Check+%26+fix+styling%22+branch%3Amain)[![Total Downloads](https://camo.githubusercontent.com/1bf0b4d5842cfba86d2c351b349390bd2dd59f9a0b44474bd72806ee0861c3da/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f617274696669636572746563682f66696c616d656e742d6d756c74692d636f6e746578742e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/artificertech/filament-multi-context)

This package allows you to register multiple filament contexts in your application with their own set of resources and pages

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

[](#installation)

You can install the package via composer:

```
composer require artificertech/filament-multi-context
```

Usage
-----

[](#usage)

create a new filament context using

```
php artisan make:filament-context FilamentTeams
```

The above command will create the following files and directories:

```
app/FilamentTeams/Pages/
app/FilamentTeams/Resources/
app/FilamentTeams/Widgets/
app/Providers/FilamentTeamsServiceProvider.php
config/filament-teams.php

```

`Filament` cannot be passed as a context to this command as it is reserved for the default filament installation

### ***Register Provider:***

[](#register-provider)

Be sure to add the `FilamentTeamsServiceProvider` class to your providers array in `config/app.php`

### Adding Resources and Pages

[](#adding-resources-and-pages)

You may now add filament resources in your FilamentTeams directories.

> ***Context Traits:*** be sure to add the ContextualPage and ContextualResource traits to their associated classes inside of your context directories. (I tried really hard with v2 to make this unnecessary but sadly here we are). Without this when filament generates navigation links it will try to use `filament.pages.*` and `filament.resources.{resource}.*` instead of `{context}.pages.*` and `{context}.resources.{resource}.*` as the route names

#### ContextualPage &amp; ContextualResource traits

[](#contextualpage--contextualresource-traits)

Pages:

```
namespace App\FilamentTeams\Pages;

use Artificertech\FilamentMultiContext\Concerns\ContextualPage;
use Filament\Pages\Page;

class Dashboard extends Page
{
    use ContextualPage;
}
```

Resources:

```
namespace App\FilamentTeams\Resources;

use Artificertech\FilamentMultiContext\Concerns\ContextualResource;
use Filament\Resources\Resource;

class UserResource extends Resource
{
    use ContextualResource;
}
```

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

[](#configuration)

The `config/filament-teams.php` file contains a subset of the `config/filament.php` configuration file. The values in the `filament-teams.php`file can be adjusted and will only affect the pages, resources, and widgets for the `filament-teams` context.

Currently the configuration values that can be modified for a specific context are:

```
'path'
'domain'
'pages'
'resources'
'widgets'
'livewire'
'middleware'

```

### ContextServiceProvider

[](#contextserviceprovider)

Your `ContextServiceProvider` found in your `app/Providers/FilamentTeamsServiceProvider.php` is an extension of the Filament `PluginServiceProvder` so features of the `PluginServiceProvider` may be used for your context. Any UserMenuItems, scripts, styles, or scriptData added to the provider will be registered for that context only

### Custom Page and Resource Routing

[](#custom-page-and-resource-routing)

If you would like more control over the way pages and resources are routed you may override the `componentRoutes()` function in your `FilamentTeamsServiceProvider`

```
protected function componentRoutes(): callable
    {
        return function () {
            Route::name('pages.')->group(function (): void {
                foreach (Facades\Filament::getPages() as $page) {
                    Route::group([], $page::getRoutes());
                }
            });

            Route::name('resources.')->group(function (): void {
                foreach (Facades\Filament::getResources() as $resource) {
                    Route::group([], $resource::getRoutes());
                }
            });
        };
    }
```

### Changing the context guard

[](#changing-the-context-guard)

By default all contexts will use the guard defined in the primary `filament.php`config file. However if you need to specify the guard for a specific context you may add the following lines to your context config file:

```
/*
    |--------------------------------------------------------------------------
    | Auth
    |--------------------------------------------------------------------------
    |
    | This is the configuration that Filament will use to handle authentication
    | into the admin panel.
    |
    */

    'auth' => [
        'guard' => 'my-custom-guard',
    ],
```

!!! The Filament Facade
-----------------------

[](#-the-filament-facade)

In order for this package to work the `filament` app service has been overriden. Each context is represented by its own `Filament\FilamentManager` object. Within your application calls to the filament facade (such as `Filament::serving`) will be proxied to the appropriate `Filament\FilamentManager` object based on the current context of your application (which is determined by the route of the request)

### Context Functions

[](#context-functions)

The following functions have been added to facilitate multiple `Filament\FilamentManger` objects in your application:

```
// retrieve the string name of the current application context
// defaults to `filament`

Filament::currentContext(): string
```

```
// retrieve the Filament\FilamentManager object for the current app context

Filament::getContext()
```

```
// retrieve the array of Filament\FilamentManager objects keyed by the context name

Filament::getContexts()
```

```
// set the current app context.
// Passing null or nothing sets the context to 'filament'

Filament::setContext(string|null $context)
```

```
// sets the context for the duration of the callback function, then resets it back to the original value
Filament::forContext(string $context, function () {
    // ...
})
```

```
// loops through each registered context (including the default 'filament' context),
// sets that context as the current context,
// runs the callback, then resets to the original value
Filament::forAllContexts(function () {
    // ...
})
```

```
// creates a new FilamentManager object and registers it under the $name context
// this method is used by your ContextServiceProvider to register your context
// you shouldn't need to use this method during normal development
Filament::addContext(string $name)
```

Testing
-------

[](#testing)

```
composer test
```

Changelog
---------

[](#changelog)

Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.

Contributing
------------

[](#contributing)

Please see [CONTRIBUTING](https://github.com/spatie/.github/blob/main/CONTRIBUTING.md) for details.

Security Vulnerabilities
------------------------

[](#security-vulnerabilities)

Please review [our security policy](../../security/policy) on how to report security vulnerabilities.

Credits
-------

[](#credits)

- [Cole Shirley](https://github.com/cole.shirley)
- [All Contributors](../../contributors)

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

39

—

LowBetter than 86% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity42

Moderate usage in the ecosystem

Community19

Small or concentrated contributor base

Maturity61

Established project with proven stability

 Bus Factor1

Top contributor holds 61.8% 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 ~31 days

Recently: every ~62 days

Total

13

Last Release

1100d ago

Major Versions

v1.0.0 → v2.0.0-beta12022-08-09

### Community

Maintainers

![](https://www.gravatar.com/avatar/26300af7b89f84f6a6b6ef2ffb592a3e5663b3d8ed7d65a6699a86aab65ed411?d=identicon)[cole.shirley](/maintainers/cole.shirley)

---

Top Contributors

[![coleshirley](https://avatars.githubusercontent.com/u/84236864?v=4)](https://github.com/coleshirley "coleshirley (47 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (11 commits)")[![github-actions[bot]](https://avatars.githubusercontent.com/in/15368?v=4)](https://github.com/github-actions[bot] "github-actions[bot] (9 commits)")[![juliomotol](https://avatars.githubusercontent.com/u/21353103?v=4)](https://github.com/juliomotol "juliomotol (6 commits)")[![iotron](https://avatars.githubusercontent.com/u/50877415?v=4)](https://github.com/iotron "iotron (1 commits)")[![josefbehr](https://avatars.githubusercontent.com/u/4368880?v=4)](https://github.com/josefbehr "josefbehr (1 commits)")[![weeg](https://avatars.githubusercontent.com/u/1826324?v=4)](https://github.com/weeg "weeg (1 commits)")

---

Tags

laravelfilamentartificertechfilament-multi-context

###  Code Quality

TestsPest

Code StyleLaravel Pint

### Embed Badge

![Health badge](/badges/artificertech-filament-multi-context/health.svg)

```
[![Health](https://phpackages.com/badges/artificertech-filament-multi-context/health.svg)](https://phpackages.com/packages/artificertech-filament-multi-context)
```

###  Alternatives

[awcodes/filament-quick-create

Plugin for Filament Admin that adds a dropdown menu to the header to quickly create new items.

246177.6k7](/packages/awcodes-filament-quick-create)[guava/filament-knowledge-base

A filament plugin that adds a knowledge base and help to your filament panel(s).

206120.5k1](/packages/guava-filament-knowledge-base)[ralphjsmit/laravel-filament-seo

A package to combine the power of Laravel SEO and Filament Admin.

15398.7k10](/packages/ralphjsmit-laravel-filament-seo)[caresome/filament-neobrutalism-theme

A neobrutalism theme for FilamentPHP admin panels

303.2k](/packages/caresome-filament-neobrutalism-theme)[andreia/filament-ui-switcher

Add a modal with options to switch between different UI layouts and styles (colors, fonts, font sizes).

233.8k](/packages/andreia-filament-ui-switcher)[guava/filament-modal-relation-managers

Allows you to embed relation managers inside filament modals.

7565.0k4](/packages/guava-filament-modal-relation-managers)

PHPackages © 2026

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