1. Go to this page and download the library: Download mevdschee/php-crud-api library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
mevdschee / php-crud-api example snippets
GET /records/categories?order=name,desc
GET /records/categories?order=id,desc&order=name
GET /records/categories?order=id,desc&size=1
GET /records/categories?order=id&page=1
GET /records/categories?order=id&page=1,50
use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\ServerRequestInterface;
use Tqdev\PhpCrudApi\Cache\Cache;
use Tqdev\PhpCrudApi\Column\ReflectionService;
use Tqdev\PhpCrudApi\Controller\Responder;
use Tqdev\PhpCrudApi\Database\GenericDB;
use Tqdev\PhpCrudApi\Middleware\Router\Router;
class MyHelloController {
private $responder;
public function __construct(Router $router, Responder $responder, GenericDB $db, ReflectionService $reflection, Cache $cache)
{
$router->register('GET', '/hello', array($this, 'getHello'));
$this->responder = $responder;
}
public function getHello(ServerRequestInterface $request): ResponseInterface
{
return $this->responder->success(['message' => "Hello World!"]);
}
}