This package brings the power of modules to Laravel Filament. It allows you to organize your filament code into fully
autonomous modules that can be easily shared and reused across multiple projects.
With this package, you can turn each of your modules into a fully functional Filament Plugin with its own resources,
pages, widgets, components and more. What's more, you don't even need to register each of these plugins in your main
Filament Panel. All you need to do is register the ModulesPlugin
in your panel, and it will take care of the rest for
you.
This package is simple a wrapper of nwidart/laravel-modules package to make it work with Laravel Filament.
v3 of this package requires the following dependencies:
You can install the package via composer:
composer require coolsam/modules
This will automatically install nwidart/laravel-modules
as well. Make sure you go through
the documentation to understand how to use the package and to configure it properly
before proceeding.
You can publish the config file with:
php artisan vendor:publish --tag="modules-config"
Alternatively, just run the installation command and follow the prompts:
php artisan modules:install
After publishing the config file, you can configure the package to your liking. The configuration file is located
at config/filament-modules.php
.
The following can be adjusted in the configuration file:
module:filament:install
command and all filament files for that module may reside inside that cluster. Otherwise, filament files will reside
in Filament/Resources, Filament/Pages, Filament/Widgets, etc.The package comes with a ModulesPlugin
that you can register in your Filament Panel. This plugin will automatically
load all the modules in your application and register them as Filament plugins.
In order to achieve this, you need to register the ModulesPlugin
in your panel of choice (e.g. Admin Panel) like so:
// e.g. in App\Providers\Filament\AdminPanelProvider.php use Filament\Plugin\ModulesPlugin;public function panel(Panel $panel): Panel{ return $panel ... ->plugin(ModulesPlugin::make());}
That's it! now you are ready to start creating some filament code in your module of choice!
If you don't have a module already, you can generate one using the module:make
command like so:
php artisan module:make MyModule
Next, run the module:filament:install
command to generate the necessary Filament files and directories in your module:
php artisan module:filament:install MyModule
This will guide you interactively on whether you want to organize your code in clusters, and whether you would like to create a default cluster. At the end of this installation, you will have the following structure in your module:
As you can see, there are two main files generated: The plugin class and optionally the cluster class. After generation, you are free to make any modifications to these classes as you may see fit.
The plugin will be loaded automatically unless the configuration is set otherwise. As a result, it will also load all its clusters automatically.
Your module is now ready to be used in your Filament Panel. Use the following commands during development to generate new resources, pages, widgets and clusters in your module:
php artisan module:make:filament-resource
Follow the interactive prompts to create a new resource in your module.
php artisan module:make:filament-page
Follow the interactive prompts to create a new page in your module.
###Creating a new widget
php artisan module:make:filament-widget
Follow the interactive prompts to create a new widget in your module.
php artisan module:make:filament-cluster
Follow the interactive prompts to create a new cluster in your module.
php artisan module:make:filament-plugin
Follow the interactive prompts to create a new plugin in your module.
composer test
Please see CHANGELOG for more information on what has changed recently.
Please see CONTRIBUTING for details.
Please review our security policy on how to report security vulnerabilities.
The MIT License (MIT). Please see License File for more information.
Sam Maosa is a Full-Stack software developer and open-source software maintainer with 10+ years of experience, mainly using the TALL stack (Tailwind, Alpine, Laravel & Livewire). His Open source contributions are currently mainly centered around FilamentPHP. He also contributes to other stacks such as Inertia.js, Vue.js, and Node.
Sam resides in Nairobi, Kenya, and is an employee of Strathmore University. His goal is to transition fully into open-source software development and maintenance and to make more contributions to the core packages of the TALL/FLAT stack.