承接 saritasa/laravel-entity-services 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

saritasa/laravel-entity-services

最新稳定版本:2.0.0

Composer 安装命令:

composer require saritasa/laravel-entity-services

包简介

Saritasa entity service for typical CRUD operations

README 文档

README

PHP Unit PHP CodeSniffer codecov PHPv Downloads

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

As Repositories layer uses laravel-repositories library.

Laravel 5.5/6.0

Install the saritasa/laravel-entity-services package:

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:

php artisan vendor:publish --tag=laravel_entity_services

It will copy file laravel_entity_services.php in config directory.

Register custom entity service implementation

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

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.

Available operations:

Create:

 $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.

Example:

 $entityServiceFactory = app(IEntityServiceFactory::class);
 $entityService = $entityServiceFactory->register(User::class, YourServiceRealization::class);

Note: Your realization must be extend EntityService class

Events

EntityCreatedEvent - Throws when entity is created.
EntityUpdatedEvent - Throws when entity is updated.
EntityDeletedEvent - Throws when entity is deleted.

Contributing

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

Make shortcuts

If you have GNU Make installed, you can use following shortcuts:

  • 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

统计信息

  • 总下载量: 14.81k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 4
  • 依赖项目数: 1
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 10
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2018-06-07

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固