Skip to content

Instantly share code, notes, and snippets.

@Phelms215
Created February 13, 2015 01:34
Show Gist options
  • Save Phelms215/ef5479aec9a35bc54f96 to your computer and use it in GitHub Desktop.
Save Phelms215/ef5479aec9a35bc54f96 to your computer and use it in GitHub Desktop.
<?php namespace App\Providers;
use Illuminate\Support\ServiceProvider;
class PluginServiceProvider extends ServiceProvider {
/**
* Bootstrap any application services.
*
* @return void
*/
public function boot()
{
//
}
/**
* Register any plugin services
*
* Scan plugin folder and dynamically register all Facades.
*
* @return void
*/
public function register()
{
$dirs = array_filter(glob(app_path() . '/Plugins/*'), 'is_dir');
foreach($dirs as $pluginPath):
$cleanUp = explode("/", $pluginPath);
$folder_name = end($cleanUp);
$className = "\\Plugins\\$folder_name";
$this->app->bind(strtolower($folder_name), $className);
endforeach;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment