| description | Create a complete PowerGrid plugin from scratch, including PHP class, Column macro, Blade view, Alpine.js component, and registration.
|
| name | create-powergrid-plugin |
What I do
Scaffold a complete external PowerGrid plugin in the user's project (NOT in the package).
When to use me
- A new interactive column behavior is needed (e.g., selectable, colorpicker, rating)
- The behavior requires its own Blade view and/or Alpine.js component
- The plugin needs to respond to user interactions via Livewire events
Quick Overview
Plugins are created in the user's project at app/PowerGrid/Plugins/{PluginName}/.
They do NOT require modifying the PowerGrid package.
Files to create:
app/PowerGrid/Plugins/{PluginName}/{PluginName}Plugin.php - Plugin class
app/PowerGrid/Plugins/{PluginName}/index.blade.php - Blade template
app/PowerGrid/Plugins/{PluginName}/index.js - Alpine.js component
app/Providers/PowerGridPluginServiceProvider.php - ServiceProvider
Files to modify:
bootstrap/providers.php - Register the ServiceProvider
app/Providers/AppServiceProvider.php - Add plugin to PowerGrid::plugins([...])
- User's PowerGrid component - Add column + hook method
Critical Rules
- Create plugins in user's project, never in the powergrid package
- ServiceProvider must call
boot() and register view namespace with loadViewsFrom()
- Alpine.js dispatch must use array format:
[field, id, value] (NOT object {field, id, value})
- Render initial values server-side with
@foreach/@selected() - do NOT use x-model for initial state
- Model
$fillable must include the field being updated
- No proxy method needed -
pgPluginListener in Listeners.php handles routing generically
Workflow
- Gather requirements (plugin name, macro signature, interaction type, hook name)
- Read
REFERENCE.md in this skill directory for templates and full details
- Create the plugin files following the templates
- Register ServiceProvider and plugin
- Add column + hook to user's component
- Verify it works
For complete templates, architecture details, and troubleshooting, see:
REFERENCE.md