Laravel - Package Development - View Components

If your package contains view components, you may use the loadViewComponentsAs method to inform Laravel how to load them. The loadViewComponentsAs method accepts two arguments: the tag prefix for your view components and an array of your view component class names. For example, if your package's prefix is courier and you have Alert and Button view components, you would add the following to your service provider's boot method:

    
    use Courier\Components\Alert;
    use Courier\Components\Button;
    
    /**
     * Bootstrap any package services.
     *
     * @return void
     */
    public function boot()
    {
        $this->loadViewComponentsAs('courier', [
            Alert::class,
            Button::class,
        ]);
    }
	

Once your view components are registered in a service provider, you may reference them in your view like so: