2017 © Pedro Peláez
 

library laravel-ddd

Generates domains for laravel Domain Driven Development

image

oleglfed/laravel-ddd

Generates domains for laravel Domain Driven Development

  • Friday, August 25, 2017
  • by olego
  • Repository
  • 1 Watchers
  • 9 Stars
  • 347 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 2 Forks
  • 1 Open issues
  • 6 Versions
  • 5 % Grown

The README.md

Laravel DDD

Domain Driven Development domains generator.

image image Build Status StyleCI, (*1)

This package is made to generate Domains, based on DB table. Package get all table fields and creates domain. With Domain creates repository, service and Infrastructure. Also the Package automatically binds generated classes to your app, so you can easily use DI or make Service by contract $service = app(UserServiceInterface::class);, (*2)

php artisan make:domain User --table=users, (*3)

Installation:

Require this package with composer using the following command:, (*4)

$ composer require oleglfed/laravel-ddd

Go to your config/app.php and add the service provider:, (*5)

\oleglfed\LaravelDDD\LaravelDddServiceProvider::class, (*6)

Usage

This package creates app/Domain and app/Infrastructure directories. So at first package should be able to create these two directories. Afterwards, you can revoke writable access from app directory., (*7)

This package requires writable permissions to config/domains directory. Before use, create config/domains directory with writable permissions or allow the package to write into config directory. It is necessary for writing domains binding. Afterwards, these domains will be bound to your app by LaravelDddServiceProvider, (*8)

$ php artisan make:domain User --table=users

To generate domain, use the make:domain artisan command. This command will create in ths Domains and Infrastructures directories inside app/ folder domain classes., (*9)

E.g. for User will be created classes, (*10)

UserEloquent, (*11)

UserRepository, (*12)

EloquentUserRepository, (*13)

UserService, (*14)

And contracts for this classes, (*15)

Available command options:

Option Description
table Based on Table will be created Eloquent, getters and setters
directory By default directory name takes from domain name. To override it --directory might be set
domain-path By default domain directory is app/Domains. To override it --domain-path might be set
infrastructure-path By default infrastructure directory is app/Infrastructures. To override it --infrastructure-path might be set

Advanced usage

This package contains a few useful methods to work with services and repositories., (*16)

    public function index(UserServiceInterface $service)
    {
        $service->all(); //Shows all records

        $service->get(1); //Shows record with ID: 1

        $servcie->findWhere(['first_name' => 'Oleg']); //Returns all records with provided where

        $servcie->deleteWhere(['first_name' => 'Oleg']); //Deletes all records with provided where

        $servcie->firstOrCreate(['email' => 'oleg.fedoliak@gmail.com']); //Returns a record with provided where, or creates it

        $servcie->firstOrNull(['email' => 'oleg.fedoliak@gmail.com']); //Returns a record with provided where, or null

        $servcie->lists(20, 10, ['first_name', 'email']); //Returns paginated list with `per page`, `offset`, `columns` (all by default) 

        $servcie->count(); //Returns count of records 

        //Create
        $user = $service->newInstance();
        $user->setFirstName('Oleg');
        $user->setEmail('oleg.fedoliak@gmail.com');

        $user = $servcie->create($user);

        //Update
        $user->setFirstName('John');
        $user = $servcie->update($user);

        //Save. There is a method which will check if record is exists, and if so will update it. Otherwise create it.
        $user = $servcie->save($user);

        //Delete
        $isDeleted = $servcie->delete($user);
    }

If your routes use resource you can explicitly bind Domains Open Providers\RouteServiceProvider and add:, (*17)

    \Route::model('user', App\Domains\User\UserEloquent::class);

Then you are able to use:, (*18)

 public function update(Request $request, UserInterface $user, UserServiceInterface $service)
 {
    dd($user); <-- will be dumped User Domain
 }        

License

The Laravel DDD Generator is free software licensed under the MIT license., (*19)

The Versions

25/08 2017

dev-master

9999999-dev https://github.com/oleglfed/laravel-ddd

Generates domains for laravel Domain Driven Development

  Sources   Download

MIT

The Requires

  • php >=5.5.0

 

The Development Requires

by Oleg Fedoliak

laravel domains package ddd domain driven development

25/08 2017

v1.1

1.1.0.0 https://github.com/oleglfed/laravel-ddd

Generates domains for laravel Domain Driven Development

  Sources   Download

MIT

The Requires

  • php >=5.5.0

 

The Development Requires

by Oleg Fedoliak

laravel domains package ddd domain driven development

25/08 2017

v1.0.1

1.0.1.0 https://github.com/oleglfed/laravel-ddd

Generates domains for laravel Domain Driven Development

  Sources   Download

MIT

The Requires

  • php >=5.5.0

 

The Development Requires

by Oleg Fedoliak

laravel domains package ddd domain driven development

25/08 2017

v1.0

1.0.0.0 https://github.com/oleglfed/laravel-ddd

Generates domains for laravel Domain Driven Development

  Sources   Download

MIT

The Requires

 

The Development Requires

by Oleg Fedoliak

laravel domains package ddd domain driven development

24/08 2017

v0.2

0.2.0.0 https://github.com/oleglfed/laravel-ddd

Generates domains for laravel Domain Driven Development

  Sources   Download

MIT

The Requires

 

The Development Requires

by Oleg Fedoliak

laravel ddd

13/05 2017

v0.1

0.1.0.0 https://github.com/oleglfed/laravel-ddd

Generates domains for laravel Domain Driven Development

  Sources   Download

The Requires

 

The Development Requires

by Oleg Fedoliak

laravel ddd