Skip to content
This repository was archived by the owner on Jun 16, 2025. It is now read-only.
CrixuAMG edited this page Mar 11, 2018 · 1 revision

Welcome to the laravel-decorators wiki!

This wiki has been written to provide documentation on how to use laravel-decorators within your Laravel 5+ project. If you've got any problems, please use this wiki, provided answers in the issues section on GitHub or create an issue yourself.

Installation

Run the following command within your terminal application:

composer require crixuamg/laravel-decorators

Then, publish the config file using

php artisan vendor:publish

Using Laravel < 5.5? Go to your config/app.php and add the service provider:

CrixuAMG\Decorators\DecoratorServiceProvider::class,

Usage

Run php artisan make:provider RepositoryServiceProvider. Then, within the newly created provider register any set of class that you want to use the decorator pattern with. Example:

    use CrixuAMG\Decorators\Handler;

    public function register() 
    {
        /**
         * User repository
         */
        decorator()->decorate(UserContract::class, [
            UserRepository::class,
            UserCache::class,
        ]);
    }

Clone this wiki locally