Writing Service Providers: The Boot Method

<?php

namespace App\Providers;

use Illuminate\Support\ServiceProvider;

class ComposerServiceProvider extends ServiceProvider
{
    /**
     * Bootstrap any application services.
     *
     * @return void
     */
    public function boot()
    {
        view()->composer('view', function () {
            //
        });
    }
}

Is called after all other service providers have been registered.

Boot Method Dependency Injection

Use Illuminate\Contracts\Routing\ResponseFactory;

public function boot(ResponseFactory $response)
{
    $response->macro('caps', function ($value) {
        //
    });
}

Writing Service Providers: The Boot Method — Structure map

Clickable & Draggable!

Writing Service Providers: The Boot Method — Related pages: