Never confuse your tabs with different Filament environments again.
Plugin Version | Filament Version | PHP Version |
---|---|---|
1.x | ^2.9.15 | > 8.0 |
2.x | 3.x | > 8.1 |
composer require pxlrbt/filament-environment-indicator
To use this plugin register it in your panel configuration:
use pxlrbt\FilamentEnvironmentIndicator\EnvironmentIndicatorPlugin;Â $panel ->plugins([ EnvironmentIndicatorPlugin::make(), ]);
Out of the box, this plugin adds a colored border to the top of the admin panel and a badge next to the search bar.
You can customize any behaviour via the plugin object.
Use php artisan vendor:publish --tag="filament-environment-indicator-views"
to publish the view to the resources/views/vendor/filament-environment-indicator
folder. After this you can customize it as you wish!
By default, the package checks whether you have Spatie permissions plugin installed and checks for a role called super_admin
. You can further customize whether the indicators should be shown.
use pxlrbt\FilamentEnvironmentIndicator\EnvironmentIndicatorPlugin;Â $panel->plugins([ EnvironmentIndicatorPlugin::make() ->visible(fn () => auth()->user()?->can('see_indicator'))]);
You can overwrite the default colors if you want your own colors or need to add more. The ->color()
method accepts any Filament's Color object or a closure that returns a color object.
use pxlrbt\FilamentEnvironmentIndicator\EnvironmentIndicatorPlugin;use Filament\Support\Colors\Color;Â $panel->plugins([ EnvironmentIndicatorPlugin::make() ->color(fn () => match (app()->environment()) { 'production' => null, 'staging' => Color::Orange, default => Color::Blue, })]);
By default, both indicators are displayed. You can turn them off separately.
use pxlrbt\FilamentEnvironmentIndicator\EnvironmentIndicatorPlugin;use Filament\Support\Colors\Color;Â $panel->plugins([ EnvironmentIndicatorPlugin::make() ->showBadge(false) ->showBorder(true)]);
You can enable the display of the current git branch in the badge via ->showGitBranch()
. This requires the exec()
function to be enabled in your PHP configuration.
use pxlrbt\FilamentEnvironmentIndicator\EnvironmentIndicatorPlugin;use Filament\Support\Colors\Color;Â $panel->plugins([ EnvironmentIndicatorPlugin::make() ->showGitBranch()]);
If you want to contribute to this packages, you may want to test it in a real Filament project:
/filament-environment-indicator
directory, create a branch for your fix, e.g. fix/error-message
.Install the packages in your app's composer.json
:
"require": { "pxlrbt/filament-environment-indicator": "dev-fix/error-message as main-dev",},"repositories": [ { "type": "path", "url": "filament-environment-indicator" }]
Now, run composer update
.
Dennis, a Filament core-team member, is dedicated to delivering high-quality plugins for your Filament projects. He is a freelance full-stack developer who works on several Laravel projects either individually or as part of small teams. In his work, he utilizes both Livewire and Inertia.