Skip to main content

Introduction

Filament’s plugin system allows you to package and distribute reusable functionality. Plugins can register resources, pages, widgets, themes, and more. They provide a clean way to extend Filament panels with custom features.

Understanding the Plugin interface

All Filament plugins implement the Filament\Contracts\Plugin interface:
  • getId() - Returns a unique identifier for the plugin
  • register() - Called when the plugin is registered with a panel
  • boot() - Called after all plugins are registered

Creating a basic plugin

Plugin configuration

Make your plugins configurable with a fluent API:
Usage:

Static make() method

Add a static make() method for convenience:

Registering resources and pages

Plugins can register complete CRUD interfaces:

Adding navigation items

Customize panel navigation from your plugin:

Using render hooks

Inject custom content into the panel:
Available render hooks:
  • panels::head.start - Start of <head>
  • panels::head.end - End of <head>
  • panels::body.start - Start of <body>
  • panels::body.end - End of <body>
  • panels::page.start - Start of page content
  • panels::page.end - End of page content
  • panels::sidebar.nav.start - Start of sidebar navigation
  • panels::sidebar.nav.end - End of sidebar navigation

Registering theme customizations

Plugins can customize the panel theme:

Middleware and authentication

Plugins can register middleware:

Using the boot() method

The boot() method is called after all plugins are registered:

Service provider integration

Create a Laravel service provider for your plugin package:

Complete plugin example

Here’s a comprehensive example of a feature-rich plugin:

Testing plugins

Test your plugins to ensure they work correctly:

Publishing your plugin

When distributing your plugin:
  1. Create a comprehensive README.md with installation instructions
  2. Add proper versioning following semantic versioning
  3. Include a LICENSE file
  4. Provide migration files if your plugin needs database tables
  5. Document all configuration options
  6. Include screenshots or demos
  7. Add tests for core functionality
  8. Publish to Packagist for easy installation

Best practices

  • Use descriptive plugin IDs that won’t conflict with others
  • Make plugins configurable rather than hard-coding values
  • Provide sensible defaults for all configuration options
  • Use the register() method for panel configuration
  • Use the boot() method for initialization that needs all plugins loaded
  • Version your plugin assets to prevent caching issues
  • Follow PSR-4 autoloading standards
  • Namespace your views, translations, and config files
  • Document all public methods and configuration options
  • Provide migration files for database changes
  • Test your plugin with multiple Filament versions
  • Use dependency injection via app() instead of new
  • Never use abbreviated variable names