Support the ongoing development of Laravel.io →
Configuration Packages Architecture
Last updated 2 years ago.
0

Also intrested in this

0

why don't you just put the middleware as needed in your app and put your app.debug conditional inside the middleware itself? in other words, add your ClockworkServiceProvider middleware to all routes or whichever routes it would normally be added to and then inside your middleware do this:

	public function handle($request, Closure $next)
	{
		if (config('app.debug'))
		{
			// do something
		}
		return $next($request);
	}
0

this would load your service provider and you could just insert it wherever you need in the kernel stack.

	public function handle($request, Closure $next)
	{
		if (config('app.debug'))
		{
			\App::register('Clockwork\Support\Laravel\ClockworkServiceProvider');
		}
		return $next($request);
	}
0

here's what i did for laravel 5.0.33. in the app\Http\Kernel.php.


    public function bootstrap() {

        parent::bootstrap(); // should have loaded environment detection now.

        if ($this->app->environment() == 'local') {
            $this->pushMiddleware('Clockwork\Support\Laravel\ClockworkMiddleware');
        }

    }

0

I use the AppServiceProvider I check the env and only load the service provider then I would not use the prependMiddleware method.

public function register()
    {
        $this->app->bind(
            'Illuminate\Contracts\Auth\Registrar',
            'App\Services\Registrar'
        );
        // if in dev mode then enable some dev tool service providers
        if ($this->app->environment() == 'local' or 'testing') {
            $this->app->register('Laracasts\Generators\GeneratorsServiceProvider');
            $this->app->register('Barryvdh\LaravelIdeHelper\IdeHelperServiceProvider');


//            $loader = AliasLoader::getInstance();
            $this->app->register('Barryvdh\Debugbar\ServiceProvider');
            $loader = AliasLoader::getInstance();
            $loader->alias('Debugbar', 'Barryvdh\Debugbar\Facade');
//            $this->app->register('Clockwork\Support\Laravel\ClockworkServiceProvider');
//            $loader->alias('Clockwork', 'Clockwork\Support\Laravel\Facade');

        }

    }

0

Sign in to participate in this thread!

Eventy

Your banner here too?

jaumesala jaumesala Joined 20 Mar 2015

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2024 Laravel.io - All rights reserved.