Enable global middleware only for one environment in Laravel 5

To achieve this simply load kernel in the service provider then call either pushMiddleware or prependMiddleware

class AppServiceProvider extends ServiceProvider
{
    /**
     * Bootstrap any application services.
     *
     * @return void
     */
    public function boot(Kernel $kernel)
    {
        if ($this->app->environment() === 'dev') {
            $kernel->prependMiddleware(ClockworkMiddleware::class);
        }
    }
}

In the kernel.php file

 //...
 protected middleware = [
    'Illuminate\Foundation\Http\Middleware\CheckForMaintenanceMode',
    'Illuminate\Cookie\Middleware\EncryptCookies',
    'Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse',
    'Illuminate\Session\Middleware\StartSession',
    'Illuminate\View\Middleware\ShareErrorsFromSession',
    'App\Http\Middleware\VerifyCsrfToken',
    (!$this->app->environment('local')) ?: 'Path/To/Package'
 ]

This should solve.