Installation:
composer require tomatophp/filament-plugins
php artisan filament-plugins:install
Add "merge-plugin": true to composer.json under "extra" > "laravel" to enable autoloading.
First Use Case: Generate a basic plugin:
php artisan make:filament-plugin ExamplePlugin
This creates a scaffold with:
PluginServiceProvider)config/example-plugin.php)Where to Look First:
app/Plugins/ (default) for generated plugins.config/filament-plugins.php for global settings.php artisan to see available plugin-related commands (e.g., make:filament-plugin, filament-plugins:publish).Plugin Development Cycle:
make:filament-plugin to scaffold a new plugin.php artisan filament-plugins:publish --plugin=ExamplePlugin
merge-plugin is enabled. Otherwise, manually register in config/app.php under providers.Integration with Filament:
MenuItem class.filament-plugins:make-resource to generate plugin-specific Filament resources (tables, forms).Widgets class in your plugin:
public static function getWidgets(): array
{
return [
\App\Plugins\ExamplePlugin\Widgets\StatsOverview::class,
];
}
Dynamic Plugin Loading:
plugin.php:
public static function getDependencies(): array
{
return ['another-plugin'];
}
Configuration Management:
config('filament-plugins.example-plugin.key') to access plugin-specific settings.php artisan vendor:publish --tag="filament-plugins-config"
Plugin Hooks:
filament-plugins.registered):
FilamentPlugins::hook('registered', function (Plugin $plugin) {
// Custom logic when plugin is registered
});
Asset Management:
webpack.mix.js:
mix.js('resources/plugins/example-plugin/js/app.js', 'public/plugins/example-plugin/js')
.postCss('resources/plugins/example-plugin/css/app.css', 'public/plugins/example-plugin/css', [
//
]);
Database Migrations:
php artisan filament-plugins:make-migration create_example_plugin_table --plugin=ExamplePlugin
Testing:
FilamentPlugins::fake() to mock plugins in tests:
use TomatoPHP\FilamentPlugins\Facades\FilamentPlugins;
FilamentPlugins::fake([
ExamplePlugin::class,
]);
Autoloading Issues:
merge-plugin is enabled in composer.json and run:
composer dump-autoload
App\Plugins\ExamplePlugin).Route Conflicts:
/plugins/{plugin-name}/.... Avoid naming conflicts by:
plugin.php:
public static function getRoutes(): array
{
return [
'prefix' => 'custom-prefix',
];
}
Asset Loading:
FilamentPlugins::asset('example-plugin::css/app.css');
Caching:
php artisan filament:cache-clear
php artisan cache:clear
Dependency Hell:
getDependencies() to explicitly declare requirements.Enable Debug Mode:
debug to true in config/filament-plugins.php to log plugin events:
'debug' => env('FILAMENT_PLUGINS_DEBUG', false),
Check Plugin Status:
filament-plugins:list command to see loaded/disabled plugins:
php artisan filament-plugins:list
Log Plugin Events:
FilamentPlugins::listen('loading', function (Plugin $plugin) {
Log::debug("Loading plugin: {$plugin->getName()}");
});
Custom Generators:
php artisan vendor:publish --tag="filament-plugins-generator"
Plugin Store:
PluginRepository to fetch remote plugins:
public static function getRemotePlugins(): array
{
return [
'github:vendor/plugin-repo' => 'https://github.com/vendor/plugin-repo',
];
}
UI Customization:
php artisan vendor:publish --tag="filament-plugins-views"
resources/views/vendor/filament-plugins/... to change default templates.API Endpoints:
plugin.php:
public static function getApiRoutes(): array
{
return [
'prefix' => 'api/plugins/example',
'middleware' => ['auth:sanctum'],
];
}
Localization:
php artisan vendor:publish --tag="filament-plugins-lang"
resources/lang/vendor/filament-plugins/.How can I help you explore Laravel packages today?