munza/serviceman

This package is abandoned and no longer maintained. No replacement package was suggested.

SOA package for Laravel 5.4.*

0.9.0 2017-03-23 18:41 UTC

This package is not auto-updated.

Last update: 2021-01-15 02:01:04 UTC


README

"Because Your Laravel App Needs Special Services!"

Package for implementing SOA (Service Oriented Architecture) pattern in Laravel 5.4.* which adds more organized folder structure to joselfonseca/laravel-tactician package. The folder structure can be configured through the config/serviceman.php file.

Installation

Set minimum-stability to dev in the composer.json file

    "minimum-stability": "dev"

To install this update your composer.json file to require

    "require": {
        "joselfonseca/laravel-tactician": "^0.3.*",
        "munza/serviceman" : "0.9.*"
    }

Or run composer require munza/serviceman joselfonseca/laravel-tactician from the command line.

Once the dependencies have been downloaded, add the service provider to your config/app.php file

    'providers' => [
        ...
        Joselfonseca\LaravelTactician\Providers\LaravelTacticianServiceProvider::class,
        Munza\Serviceman\ServicemanServiceProvider::class,
        ...
    ]

Publish the configuration file. Create a new command class (with handler);

    php artisan vendor:publish

Usage

Create a new service class:

    php artisan make:service User

Create a new command class (with handler):

    php artisan make:service:command Register User

Create a new command class (without handler):

    php artisan make:service:command Register User --no-handler

Create a new handler class:

    php artisan make:service:handler RegisterHandler Register User

Create a new middleware class:

    php artisan make:service:middleware RegisterValidator User

Configuration

Edit config/serviceman.php for generator configuration.

    ...
    'generator'  => [
        'basePath' => app_path(),
        'paths' => [
            'service'    => 'Services',
            'command'    => 'Services\\{{ service }}',
            'handler'    => 'Services\\{{ service }}',
            'middleware' => 'Services\\{{ service }}',
        ],
    ],
    ...

{{ service }} will be replaced with name of the service. For example if following command is used -

    php artisan make:service:command Register User

Then, app/Services/User/Register.php file will be generated, where User is the name of the service that has replaced {{ service }}.

Example

Please check joselfonseca/laravel-tactician packge for more information. Also check https://gist.github.com/joselfonseca/24ee0e96666a06b16f92 for a working example.

Issues

If you discover any issues, please open an issue using the issue tracker. But take a look at the previous issues before creating a new one to avoid duplication.

License

The MIT License (MIT). Please see License for more information.