Skip to content

Commit

Permalink
Merge pull request #3 from isaeken/1.5
Browse files Browse the repository at this point in the history
v1.5
  • Loading branch information
isaeken authored Jun 27, 2021
2 parents 99b3609 + e751fae commit 6d5e0ef
Show file tree
Hide file tree
Showing 5 changed files with 120 additions and 5 deletions.
42 changes: 38 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,20 +16,47 @@ Make and add own plugins to your script and make it flexible
- Enable, disable or load plugins in runtime
- Detailed execution info like extension function executed seconds

## Installation

## Roadmap
Install plugin-system with composer

- Laravel integration
```bash
composer require isaeken/plugin-system
```


## Installation
## Installation in Laravel

Install plugin-system with composer

```bash
composer require isaeken/plugin-system
```

Publish configuration file

```bash
php artisan vendor:publish --provider="IsaEken\PluginSystem\PluginSystemServiceProvider"
```

Set your configuration

```php
// config/plugins.php
<?php

return [
'directory' => base_path('plugins'),
'nested' => false,
'folders' => true,
];
```

(Optionally)
Add provider to ``config/app.php``
```php
\IsaEken\PluginSystem\PluginSystemServiceProvider::class
```

## Example

```php
Expand All @@ -40,6 +67,13 @@ if (! $pluginSystem->execute('hello_world')) {
}
```

### In Laravel

```php
if (! app()->plugins->execute('hello_world')) {
return 'some plugins given an error.';
}
```

## Running Tests

Expand Down
12 changes: 11 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "isaeken/plugin-system",
"version": "1.5.0",
"version": "1.5.3",
"type": "library",
"description": "Plugin support and management library for your project",
"keywords": ["plugin", "extension", "support", "management"],
Expand All @@ -20,6 +20,16 @@
"config": {
"sort-packages": true
},
"extra": {
"laravel": {
"provider": [
"IsaEken\\PluginSystem\\PluginSystemServiceProvider"
],
"aliases": {
"PluginSystem": "IsaEken\\PluginSystem\\PluginSystemFacade"
}
}
},
"scripts": {
"test": "vendor/bin/phpunit"
},
Expand Down
7 changes: 7 additions & 0 deletions config/plugins.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?php

return [
'directory' => base_path('plugins'),
'nested' => false,
'folders' => true,
];
18 changes: 18 additions & 0 deletions src/PluginSystemFacade.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?php


namespace IsaEken\PluginSystem;


use Illuminate\Support\Facades\Facade;

class PluginSystemFacade extends Facade
{
/**
* @return string
*/
protected static function getFacadeAccessor(): string
{
return 'plugins';
}
}
46 changes: 46 additions & 0 deletions src/PluginSystemServiceProvider.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
<?php


namespace IsaEken\PluginSystem;


use Illuminate\Support\ServiceProvider;

class PluginSystemServiceProvider extends ServiceProvider
{
/**
* Bootstrap the application services.
*
* @return void
*/
public function boot()
{
$this->app->bind('plugins', function ($app) {
if (! is_dir(config('plugins.directory'))) {
mkdir(config('plugins.directory'));
}

return (new PluginSystem(config('plugins.directory')))->autoload(
null,
config('plugins.nested'),
config('plugins.folders'),
);
});

if ($this->app->runningInConsole()) {
$this->publishes([
__DIR__ . '/../config/plugins.php' => config_path('plugins.php'),
], 'config');
}
}

/**
* Register the application services.
*
* @return void
*/
public function register()
{
$this->mergeConfigFrom(__DIR__ . '/../config/plugins.php', 'plugins');
}
}

0 comments on commit 6d5e0ef

Please sign in to comment.