mezon / crud-service
Small crud-service script
Installs: 1 849
Dependents: 1
Suggesters: 0
Security: 0
Stars: 8
Watchers: 4
Forks: 0
Open Issues: 0
Requires
- php: >=7.2.0
- mezon/crud-service-model: 1.2.*
- mezon/fields-set: 1.0.*
- mezon/filter: 1.0.*
- mezon/security: 1.1.*
- mezon/security-provider: >=1.1.2 <1.2.0
- mezon/service: 1.6.*
- mezon/service-logic: >=1.3.1 <1.4.0
Requires (Dev)
- phpunit/phpunit: ^8.5
- vimeo/psalm: ^4.2
README
Installation
Just print in console
composer require mezon/crud-service
And that's all )
First steps
Now we are ready to create out first CRUD service. Here it is:
/** * Service class */ class TodoService extends \Mezon\CrudService\CrudService { /** * Constructor */ public function __construct() { parent::__construct([ 'fields' => [ 'id' => [ 'type' => 'integer' ], 'title' => [ 'type' => 'string' ] ], 'table-name' => 'records', 'entity-name' => 'record' ]); } } $service = new TodoService(); $service->run();
The main part of this listing is:
parent::__construct([ 'fields' => [ 'id' => [ 'type' => 'integer' ], 'title' => [ 'type' => 'string' ] ], 'table-name' => 'records', 'entity-name' => 'record' ]);
Here we describe a list of fields of our entity, table name where it is stored and entity name.
Default endpoints
Out of the box a list of CRUD endpoints are available:
GET /list/ GET /all/ GET /exact/list/[il:ids]/ GET /exact/[i:id]/ GET /fields/ POST|PUT /delete/[i:id]/ POST|DELETE /delete/ POST|PUT /create/ POST /update/[i:id]/ GET /new/from/[s:date]/ GET /records/count/ GET /last/[i:count]/ GET /records/count/[s:field]