PHP Classes

File: README.md

Recommend this page to a friend!
  Classes of Alexey Dodonov   Mezon PHP CRUD Generator Service   README.md   Download  
File: README.md
Role: Documentation
Content type: text/markdown
Description: Documentation
Class: Mezon PHP CRUD Generator Service
Generate Web service that performs CRUD operations
Author: By
Last change:
Date: 3 years ago
Size: 1,756 bytes
 

Contents

Class file image Download

Set of classes for creating CRUD services Build Status codecov

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]