Register plugin from service provider

Is it possible to register a plugin from the package's service provider? Instead of registering the plugin mannualy in the project's PanelProvider?
6 Replies
LeandroFerreira
you could try this in the AppServiceProvider
public function boot(): void
{
if ($currentPanel = filament()->getCurrentPanel()) {
$currentPanel->plugins([
XXPlugin::make(),
ZZPlugin::make(),
]);
}
}
public function boot(): void
{
if ($currentPanel = filament()->getCurrentPanel()) {
$currentPanel->plugins([
XXPlugin::make(),
ZZPlugin::make(),
]);
}
}
Jacob
JacobOP3w ago
This does load the plugin, but I get some weird errors from plugins loaded by my plugin and widget blade files not loaded. It seems that it doesn't load any plugins and widgets from my package anymore, when I do it that way.
LeandroFerreira
Explain what you are trying to do
Jacob
JacobOP3w ago
I have a Laravel composer package/ Filament plugin. When someone installs the package using composer I want that the Filament plugin is automatically loaded. So that the user doesn't have to add it manually to the ->plugins() in their AdminPanelProvider class.
LeandroFerreira
I think the configurability of a plugin depends on its purpose and functionality. For instance Spatie settings doesn't require panel specific configurations. Spatie translatable may need to adapt to different contexts depending on the panel it is associated.
Filament
Spatie Settings by Filament - Filament
Filament support for Spatie's Laravel Settings package.
Filament
Spatie Translatable by Filament - Filament
Filament support for Spatie's Laravel Translatable package.
Jacob
JacobOP3w ago
Both packages don't have what I want. I simply want to load my Filament plugin without manualy registrering it in my AdminPanelProvider class.

Did you find this page helpful?