BladePlugin automatically discovers and registers Blade components from all enabled modules, making them available in your views with module-specific prefixes.
Overview
This plugin scans modules for Blade components (both class-based and anonymous) and registers them with Laravel’s Blade compiler. Components are prefixed with the module name for clear namespacing.Source Location
InterNACHI\Modular\Plugins\BladePlugin
Activation
The plugin uses theAfterResolving attribute to activate when Blade is resolved:
This plugin automatically activates after the Blade compiler is resolved from the service container.
How It Works
1. Discovery Phase
Thediscover() method finds both component files and directories:
2. Registration Phase
Thehandle() method registers components with Blade:
Component Types
Class-Based Components
Class-based components are registered with their fully qualified class name:Anonymous Components
Anonymous components in theresources/views/components directory are also discovered:
Naming Convention
All components are prefixed with the module name followed by
:: (double colon). This prevents naming conflicts between modules.blog:
- Component:
PostCard.php - Usage:
<x-blog::post-card />
user-management:
- Component:
ProfileWidget.php - Usage:
<x-user-management::profile-widget />
Example Component
Class-Based Component
Component View
Usage
Dependencies
Illuminate\View\Compilers\BladeCompiler- Blade compiler instanceInterNACHI\Modular\Support\FinderFactory- File discovery