PHPackages                             soysaltan/laravel-plugin-system - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Framework](/categories/framework)
4. /
5. soysaltan/laravel-plugin-system

ActiveLibrary[Framework](/categories/framework)

soysaltan/laravel-plugin-system
===============================

A comprehensive Laravel plugin system with automatic registration of routes, controllers, services, views, and configs

v1.7.0(7mo ago)20101MITPHPPHP ^8.1

Since Oct 5Pushed 7mo agoCompare

[ Source](https://github.com/paramientos/laravel-plugin-system)[ Packagist](https://packagist.org/packages/soysaltan/laravel-plugin-system)[ RSS](/packages/soysaltan-laravel-plugin-system/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (8)Dependencies (6)Versions (17)Used By (0)

Laravel Plugin System
=====================

[](#laravel-plugin-system)

An extensive Laravel plugin system that provides automatic registration of routes, controllers, services, views, and configurations for modular application development.

Features
--------

[](#features)

- **Automatic Plugin Discovery** - Automatically scans and registers plugins
- ️ **Route Registration** - Auto-registers plugin routes with customizable prefixes
- **Controller Binding** - Automatically binds plugin controllers to the service container
- **Service Registration** - Registers services as singletons with interface binding support
- **View Integration** - Seamless integration with Laravel views and Livewire Volt
- ️ **Config Management** - Automatic configuration loading and merging
- **Plugin Generator** - Artisan command to create new plugins with boilerplate code
- **Component Generator** - Create commands, controllers, listeners, events, and views within plugins (v1.5)
- **Component Management** - Add components to existing plugins with duplicate detection (v1.5)

Installation
------------

[](#installation)

Install the package via Composer:

```
composer require soysaltan/laravel-plugin-system
```

Publish the configuration file:

```
php artisan vendor:publish --tag=laravel-plugin-system-config
```

Key Features (v1.5)
-------------------

[](#key-features-v15)

### Smart Plugin Management

[](#smart-plugin-management)

- **Existing Plugin Detection**: Automatically detects if a plugin already exists
- **Component Addition**: Add new components to existing plugins without recreation
- **Duplicate Prevention**: Warns and skips if component already exists
- **Flexible Component Creation**: Create individual or multiple components at once

### Supported Components

[](#supported-components)

- **Commands**: Custom Artisan commands with proper signatures
- **Controllers**: RESTful controllers with CRUD operations (extends Laravel Controller)
- **Events**: Broadcastable events with proper structure
- **Listeners**: Queue-enabled listeners with error handling
- **Views**: Blade templates or Livewire Volt components
- **Routes**: RESTful route definitions with proper namespacing (v1.5)
- **Enums**: PHP 8.1+ enums with string backing type
- **Traits**: Reusable trait classes (concerns) for shared functionality
- **Providers**: Service providers automatically created for each plugin

Configuration
-------------

[](#configuration)

The configuration file `config/laravel-plugin-system.php` allows you to customize:

```
return [
    // Path where plugins are stored
    'plugins_path' => app_path('Plugins'),

    // Base namespace for plugins
    'plugin_namespace' => 'App\\Plugins',

    // Whether to prefix routes with 'plugins/'
    'use_plugins_prefix_in_routes' => false,

    // Default view type for new plugins
    'default_view_type' => 'volt', // 'volt' or 'blade'

    // Enable/disable Volt support
    'enable_volt_support' => true,
];
```

Usage
-----

[](#usage)

### Creating a Plugin

[](#creating-a-plugin)

Use the Artisan command to create a new plugin:

```
# Create plugin with default view type (configured in config)
php artisan make:plugin MyAwesomePlugin

# Create plugin with Volt views
php artisan make:plugin MyAwesomePlugin --view-type=volt

# Create plugin with traditional Blade views
php artisan make:plugin MyAwesomePlugin --view-type=blade

# Auto-detect best view type based on configuration and availability
php artisan make:plugin MyAwesomePlugin --view-type=auto
```

### Creating Plugin Components (v1.5)

[](#creating-plugin-components-v15)

Generate specific components within your plugin:

```
# Create a command within the plugin
php artisan make:plugin MyAwesomePlugin --command=ProcessDataCommand

# Create a controller within the plugin
php artisan make:plugin MyAwesomePlugin --controller=ApiController

# Create an event within the plugin
php artisan make:plugin MyAwesomePlugin --event=DataProcessedEvent

# Create a listener within the plugin
php artisan make:plugin MyAwesomePlugin --listener=SendNotificationListener

# Create a view within the plugin
php artisan make:plugin MyAwesomePlugin --view=dashboard

# Create routes for the plugin (v1.5)
php artisan make:plugin MyAwesomePlugin --route

# Create an enum within the plugin
php artisan make:plugin MyAwesomePlugin --enum=Status

# Create a trait within the plugin
php artisan make:plugin MyAwesomePlugin --trait=Cacheable

# Combine multiple components
php artisan make:plugin MyAwesomePlugin --command=ProcessCommand --controller=ProcessController --event=ProcessedEvent --enum=Status --trait=Cacheable --route
```

### Adding Components to Existing Plugins (v1.5)

[](#adding-components-to-existing-plugins-v15)

You can add new components to existing plugins without recreating them:

```
# Add a command to existing plugin
php artisan make:plugin ExistingPlugin --command=NewCommand

# Add multiple components to existing plugin
php artisan make:plugin ExistingPlugin --controller=ApiController --event=UserRegistered --enum=Status --trait=Cacheable --route

# If component already exists, it will be skipped with a warning
php artisan make:plugin ExistingPlugin --command=ExistingCommand
# Output: Command file 'ExistingCommand.php' already exists in plugin 'ExistingPlugin'. Skipping...
```

This creates the following structure:

```
app/Plugins/MyAwesomePlugin/
├── config.php                          # Plugin configuration
├── routes.php                          # Plugin routes
├── MyAwesomePluginProvider.php         # Service provider (auto-created)
├── Controllers/
│   └── MyAwesomePluginController.php   # Plugin controller
├── Services/
│   ├── MyAwesomePluginService.php      # Plugin service
│   └── MyAwesomePluginServiceInterface.php # Service interface
├── Commands/                           # Generated commands (v1.5)
│   └── ProcessDataCommand.php
├── Events/                             # Generated events (v1.5)
│   └── DataProcessedEvent.php
├── Listeners/                          # Generated listeners (v1.5)
│   └── SendNotificationListener.php
├── Status.php                          # Generated enum
├── Cacheable.php                       # Generated trait
└── Views/
    └── index.blade.php                 # Livewire Volt component or Blade view

```

### Plugin Structure

[](#plugin-structure)

#### Config File (`config.php`)

[](#config-file-configphp)

```
