pxlrbt/filament-environment-indicator
Composer 安装命令:
composer require pxlrbt/filament-environment-indicator
包简介
Indicator for the current environment inside Filament
README 文档
README
Filament Environment Indicator
Never confuse your tabs with different Filament environments again.
Installation via Composer
| Plugin Version | Filament Version | PHP Version |
|---|---|---|
| 1.x | ^2.9.15 | > 8.0 |
| 2.x | 3.x | > 8.1 |
| 3.x | 4.x, 5.x | > 8.1 |
composer require pxlrbt/filament-environment-indicator
Usage
To use this plugin register it in your panel configuration:
use pxlrbt\FilamentEnvironmentIndicator\EnvironmentIndicatorPlugin; $panel ->plugins([ EnvironmentIndicatorPlugin::make(), ]);
Configuration
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.
Customizing the view
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!
Visibility
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')) ]);
Environment
By default, the environment is resolved from app()->environment() (i.e. the APP_ENV value). You can override it with a static string or a closure:
use pxlrbt\FilamentEnvironmentIndicator\EnvironmentIndicatorPlugin; $panel->plugins([ EnvironmentIndicatorPlugin::make() ->environment(fn () => config('app.custom_env', app()->environment())) ]);
This affects the badge label, as well as the default color, badge visibility, and border visibility which all key off the environment value.
Colors
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, }) ]);
Indicators
By default, both indicators are displayed on non-production environments. You can turn them off separately.
use pxlrbt\FilamentEnvironmentIndicator\EnvironmentIndicatorPlugin; use Filament\Support\Colors\Color; $panel->plugins([ EnvironmentIndicatorPlugin::make() ->showBadge(false) ->showBorder(true) ]);
Badge position
By default, badge position is \Filament\View\PanelsRenderHook::GLOBAL_SEARCH_BEFORE.
use Filament\View\PanelsRenderHook; use pxlrbt\FilamentEnvironmentIndicator\EnvironmentIndicatorPlugin; $panel->plugins([ EnvironmentIndicatorPlugin::make() ->badgePosition(PanelsRenderHook::TOPBAR_LOGO_BEFORE) ]);
Git Branch
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() ]);
Debug Mode Warning
You can enable a debug mode warning for every environment or just for production by using ->showDebugModeWarning()/->showDebugModeWarningInProduction()
use pxlrbt\FilamentEnvironmentIndicator\EnvironmentIndicatorPlugin; use Filament\Support\Colors\Color; $panel->plugins([ EnvironmentIndicatorPlugin::make() ->showDebugModeWarningInProduction() ]);
Contributing
If you want to contribute to this packages, you may want to test it in a real Filament project:
- Fork this repository to your GitHub account.
- Create a Filament app locally.
- Clone your fork in your Filament app's root directory.
- In the
/filament-environment-indicatordirectory, 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.
Credits
pxlrbt/filament-environment-indicator 适用场景与选型建议
pxlrbt/filament-environment-indicator 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 1.21M 次下载、GitHub Stars 达 151, 最近一次更新时间为 2022 年 07 月 15 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「filament」 「laravel-filament」 「environment indicator」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 pxlrbt/filament-environment-indicator 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 pxlrbt/filament-environment-indicator 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 pxlrbt/filament-environment-indicator 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Environment processor and contexts autoloader
The tenancy/tenancy identification driver using environment variables
Multiple cascading environmental configuration files support for Laravel 5
Change the default avatar url provider with one for inline SVGs
An environment variable convenience library extension for vlucas/phpdotenv
Spotlight for Filament Admin
统计信息
- 总下载量: 1.21M
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 152
- 点击次数: 26
- 依赖项目数: 13
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2022-07-15

