https://github.com/alexdodonov/mezon-crud-service
CRUD service classes
https://github.com/alexdodonov/mezon-crud-service
crud crud-api crud-functionality crud-generator crud-operations microservice php
Last synced: 3 months ago
JSON representation
CRUD service classes
- Host: GitHub
- URL: https://github.com/alexdodonov/mezon-crud-service
- Owner: alexdodonov
- Created: 2020-02-18T21:52:14.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2022-06-20T17:10:39.000Z (over 3 years ago)
- Last Synced: 2025-06-15T17:22:34.326Z (4 months ago)
- Topics: crud, crud-api, crud-functionality, crud-generator, crud-operations, microservice, php
- Language: PHP
- Homepage: https://twitter.com/mezonphp
- Size: 83 KB
- Stars: 8
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Set of classes for creating CRUD services
[](https://opencollective.com/mezon-router) [](https://travis-ci.com/alexdodonov/mezon-crud-service) [](https://codecov.io/gh/alexdodonov/mezon-crud-service)## 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:
```PHP
/**
* 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:
```PHP
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:
```PHP
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]
```