2017 © Pedro Peláez
 

library laravel-entity-services

Saritasa entity service for typical CRUD operations

image

saritasa/laravel-entity-services

Saritasa entity service for typical CRUD operations

  • Wednesday, August 1, 2018
  • by saritasa
  • Repository
  • 6 Watchers
  • 0 Stars
  • 52 Installations
  • PHP
  • 1 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 3 Versions
  • 0 % Grown

The README.md

Laravel Entity Services

PHP Unit PHP CodeSniffer codecov PHPv Downloads, (*1)

Library for fast build laravel based application with simple CRUD operations.

As Repositories layer uses laravel-repositories library., (*2)

Laravel 5.5/6.0

Install the saritasa/laravel-entity-services package:, (*3)

bash $ composer require saritasa/laravel-entity-services ```  
## Usage    
### Get service for model: 
 ```php    
 $entityServiceFactory = app(IEntityServiceFactory::class);  
 $entityService = $entityServiceFactory->build(User::class);
 ``` 
 *Note: if entity class not exists, EntityServiceException will be thrown
## Configuration
### Publish file
To publish configuration file you can run next command:  
```bash  
php artisan vendor:publish --tag=laravel_entity_services

It will copy file laravel_entity_services.php in config directory., (*4)

Register custom entity service implementation

To register your own IEntityService implementation you can put it into configuration file, like:, (*5)

return [
 'bindings' => [\App\Models\User::class => \App\EntityServices\UserEntityService::class,],];

NOTE: Just remember that default IEntityServiceFactory implementation can work only with classes extended from EntityService. If you want change this behavior you should add your own implementation., (*6)

Available operations:

Create:

php $createdModel = $entityService->create($params); #### Update:
php $entityService->update($model, $params); #### Delete:
php $entityService->delete($model); ### Custom service for entity:
If you need use custom service for some entity, you can register it in factory using register method., (*7)

Example: php $entityServiceFactory = app(IEntityServiceFactory::class); $entityService = $entityServiceFactory->register(User::class, YourServiceRealization::class); Note: Your realization must be extend EntityService class, (*8)

Events

EntityCreatedEvent - Throws when entity is created.
EntityUpdatedEvent - Throws when entity is updated.
EntityDeletedEvent - Throws when entity is deleted., (*9)

Contributing

  1. Create fork, checkout it
    1. Develop locally as usual. Code must follow PSR-1, PSR-2 -
      run PHP_CodeSniffer to ensure, that code follows style guides
    2. Cover added functionality with unit tests and run PHPUnit to make sure, that all tests pass
    3. Update README.md to describe new or changed functionality
    4. Add changes description to CHANGES.md file. Use Semantic Versioning convention to determine next version number.
    5. When ready, create pull request

Make shortcuts

If you have GNU Make installed, you can use following shortcuts:, (*10)

  • make cs (instead of php vendor/bin/phpcs) -
    run static code analysis with PHP_CodeSniffer
    to check code style
  • make csfix (instead of php vendor/bin/phpcbf) -
    fix code style violations with PHP_CodeSniffer
    automatically, where possible (ex. PSR-2 code formatting violations)
  • make test (instead of php vendor/bin/phpunit) -
    run tests with PHPUnit
  • make install - instead of composer install * make all or just make without parameters -
    invokes described above install, cs, test tasks sequentially -
    project will be assembled, checked with linter and tested with one single command

Resources

The Versions

01/08 2018

dev-master

9999999-dev

Saritasa entity service for typical CRUD operations

  Sources   Download

MIT

The Requires

 

The Development Requires

by Eugene Mosunov

laravel php saritasa

01/08 2018

1.1.0

1.1.0.0

Saritasa entity service for typical CRUD operations

  Sources   Download

MIT

The Requires

 

The Development Requires

by Eugene Mosunov

laravel php saritasa

07/06 2018

1.0

1.0.0.0

Saritasa entity service for typical CRUD operations

  Sources   Download

MIT

The Requires

 

The Development Requires

by Eugene Mosunov

laravel php saritasa