PHP Classes

Laravel Plugin System: Extend Laravel application features using plugins

Recommend this page to a friend!
  Info   View files Documentation   View files View files (14)   DownloadInstall with Composer Download .zip   Reputation   Support forum   Blog (1)    
Last Updated Ratings Unique User Downloads Download Rankings
2021-09-22 (2 months ago) RSS 2.0 feedNot yet rated by the usersTotal: 38 This week: 1All time: 10,267 This week: 350Up
Version License PHP version Categories
laravel-plugins 1.0.0The PHP License5PHP 5, Libraries, Language, Design Pa...
Description Author

This package can extend Laravel application features using plugins.

It provides base classes that applications can extend to manage plugins that implement new features.

Plugins can be a set of classes that implement new models, views, and controllers.

Innovation Award
PHP Programming Innovation award nominee
September 2021
Number 8
Plugins are additional components that can extend the functionality of an application or package.

Therefore those plugins can be helpful to improve the utility of an existing package.

This package implements the base of a plugin system that can improve the functionality of a PHP package based on the Laravel framework.

Manuel Lemos
Picture of Arumugam P
  Performance   Level  
Name: Arumugam P <contact>
Classes: 5 packages by
Country: India India
Age: 31
All time rank: 3136208 in India India
Week rank: 337 Up30 in India India Up
Innovation award
Innovation award
Nominee: 2x

Winner: 1x

Details

laravel-plugins

Plugin system for Laravel 5.x and Lumen 5.x. Plugins can overwrite and extend each other.

Usage

For Lumen add to bootstrap/app.php: $app->register(\Astutesixface\LaravelPlugins\PluginServiceProvider::class);

For Laravel add to 'providers' array in config/app.php: \Astutesixface\LaravelPlugins\PluginServiceProvider::class,

Create a plugin

Structure

Plugins must be in app/Plugins. Example plugin structure: - Test - Http

- Controllers
  - TestController.php

- views

- test.blade.php

- migrations

- 2018_06_15_000000_create_test_table.php

- routes.php - TestPlugin.php

The TestPlugin class must extend the Astutesixface\LaravelPlugins\Plugin class, containing a unique $name property and a boot() method.

Views

In the boot() method of your plugin call $this->enableViews(). Optional you can pass a relative path to the views directory, default to views. Views automatically have a namespace ("plugin:{name}"), the name is defined by the the main plugin class in a camel case format, with Plugin stripped from the end. For the example above it would be plugin:test. To render a view you can either write the namespace yourself or use the helper method view() in the plugin class. For example view('plugin:test::some.view.name');

Routes

In the boot() method of your plugin call $this->enableRoutes(). Optional you can pass a relative path to the routes file, default to routes.php. You automatically have access to the $app variable. Routes are automatically grouped to your plugin namespace, so you only have to type the controller name without the namespace.

Controllers

Controllers must be in PluginDirectory->Http->Controllers.

Migrations

In the boot() method of your plugin call $this->enableMigrations(). Optional you can pass a relative path to the migrations directory, default to migrations. Keep in mind that migrations must follow the yyyy_mm_dd_tttt_<name>.php naming convention, for example 2014_10_12_000000_create_users_table.php would be a valid migration.

How to extend another plugin

see examples/extend

ToDo

  • Move plugin directory and project namespace to publishable config file
  Files folder image Files  
File Role Description
Files folder image.github (1 directory)
Files folder imageexamples (1 directory)
Files folder imagesrc (5 files)
Plain text file composer.json Data Auxiliary data
Plain text file README.md Doc. Documentation

  Files folder image Files  /  .github  
File Role Description
Files folder imageworkflows (1 file)

  Files folder image Files  /  .github  /  workflows  
File Role Description
  Plain text file laravel.yml Data Auxiliary data

  Files folder image Files  /  examples  
File Role Description
Files folder imageextend (2 directories)

  Files folder image Files  /  examples  /  extend  
File Role Description
Files folder imageTest (2 files, 2 directories)
Files folder imageTestExtension (1 file, 1 directory)

  Files folder image Files  /  examples  /  extend  /  Test  
File Role Description
Files folder imageHttp (1 directory)
Files folder imageviews (1 file)
  Plain text file routes.php Class Class source
  Plain text file TestPlugin.php Class Class source

  Files folder image Files  /  examples  /  extend  /  Test  /  Http  
File Role Description
Files folder imageControllers (1 file)

  Files folder image Files  /  examples  /  extend  /  Test  /  Http  /  Controllers  
File Role Description
  Plain text file TestController.php Class Class source

  Files folder image Files  /  examples  /  extend  /  Test  /  views  
File Role Description
  Plain text file test.blade.php Aux. Auxiliary script

  Files folder image Files  /  examples  /  extend  /  TestExtension  
File Role Description
Files folder imagePlugins (1 directory)
  Plain text file TestExtensionPlugin.php Class Class source

  Files folder image Files  /  examples  /  extend  /  TestExtension  /  Plugins  
File Role Description
Files folder imageTest (1 directory)

  Files folder image Files  /  examples  /  extend  /  TestExtension  /  Plugins  /  Test  
File Role Description
Files folder imageHttp (1 directory)

  Files folder image Files  /  examples  /  extend  /  TestExtension  /  Plugins  /  Test  /  Http  
File Role Description
Files folder imageControllers (1 file)

  Files folder image Files  /  examples  /  extend  /  TestExtension  /  Plugins  /  Test  /  Http  /  Controllers  
File Role Description
  Plain text file TestController.php Class Class source

  Files folder image Files  /  src  
File Role Description
  Plain text file ClassLoader.php Class Class source
  Plain text file Plugin.php Class Class source
  Plain text file PluginExtender.php Class Class source
  Plain text file PluginManager.php Class Class source
  Plain text file PluginServiceProvider.php Class Class source

 Version Control Unique User Downloads Download Rankings  
 100%
Total:38
This week:1
All time:10,267
This week:350Up
For more information send a message to info at phpclasses dot org.