Giter Site home page Giter Site logo

laravel-domain-commands's Introduction

Laravel Domain Commands

The signifly/laravel-domain-commands package adds a handful of useful Artisan commands to your Laravel application. It assumes you are utilizing the Domain Driven Design approach.

It is heavily inspired by the DDD approach mentioned in this great article by Brent from Spatie.

In addition, it assumes that you have a separate namespace for your domain. Take a look of this example of the autoload section from a composer.json file:

{
    "autoload": {
        "psr-4": {
            "App\\" : "app/App/",
            "Domain\\" : "app/Domain/",
            "Support\\" : "app/Support/"
        },
        "classmap": [
            "database"
        ],
        "files": [
            "app/helpers.php"
        ]
    }
}

Basic Usage

The package comes with a handful of commands out of the box.

Actions

Generate a new Action using the domain:action command:

php artisan domain:action CreateUserAction -d User

NOTE: You may use the -d|--domain option to specify the given domain for the action. If you do not specify a domain, it will be generated within the default namespace. You may configure that in the config file.

Data Transfer Objects

Generate a new Data Transfer Object class using the domain:dto command:

php artisan domain:dto UserData -d User

Enums

Generate a new Enum class using the domain:enum command:

php artisan domain:enum UserType -d User

Events

Generate a new Event class using the domain:event command:

php artisan domain:event UserCreated -d User

Models

Generate a new Eloquent model class using the domain:model command:

php artisan domain:model User -d User

Observers

Generate a new Observer class using the domain:observer command:

php artisan domain:observer UserObserver -d User

Policies

Generate a new Policy class using the domain:policy command:

php artisan domain:policy UserPolicy -d User

Rules

Generate a new Rule class usign the domain:rule command:

php artian domain:rule CustomEmailRule -d User

Installation

You can install the package via composer:

composer require signifly/laravel-domain-commands

The package will automatically register itself.

You can optionally publish the config file with:

php artisan vendor:publish --tag="domain-commands-config"

Testing

composer test

Security

If you discover any security issues, please email [email protected] instead of using the issue tracker.

Credits

License

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

laravel-domain-commands's People

Contributors

pactode avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.