Skip to content

Instantly share code, notes, and snippets.

@NBZ4live
Created March 6, 2018 14:30
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save NBZ4live/98663326065ba0860c679ac411d87f80 to your computer and use it in GitHub Desktop.
Save NBZ4live/98663326065ba0860c679ac411d87f80 to your computer and use it in GitHub Desktop.
PHP-PM Lumen adapter
<?php
namespace App\PHPPM;
use Illuminate\Container\BoundMethod;
use Illuminate\Support\ServiceProvider;
use PHPPM\Bootstraps\Laravel;
class LumenAdapter extends Laravel
{
/**
* @param \Illuminate\Contracts\Foundation\Application $app
*/
public function postHandle($app)
{
$this->resetProvider(\App\Providers\AuthServiceProvider::class);
$this->resetProvider(\Illuminate\Session\SessionServiceProvider::class);
}
/**
* @param \Illuminate\Support\ServiceProvider|string $provider
*/
protected function resetProvider($provider)
{
if (! $provider instanceof ServiceProvider) {
$provider = new $provider($this->app);
}
if (method_exists($provider, 'register')) {
$provider->register();
}
if (method_exists($provider, 'boot')) {
BoundMethod::call($this->app, [$provider, 'boot']);
}
}
}
@isbkch
Copy link

isbkch commented Mar 6, 2019

How do you use this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment