1. Go to this page and download the library: Download saidqb/core-php 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/ */
use Saidqb\CorePhp\Pagination;
$pagination = Pagination::make()->totalItems(100)->itemPerPage(10)->currentPage(1)->get();
use Saidqb\CorePhp\Response;
Response::make()->response([], ResponseCode::HTTP_OK, ResponseCode::HTTP_OK_MESSAGE, 0)->send();
// list item
Response::make()->response(['items' => $items, 'pagination' => $pagination])->send();
// single item
Response::make()->response(['item' => $item])->send();
use Saidqb\CorePhp\Response;
use Saidqb\CorePhp\ResponseCode;
public $res;
public function __construct()
{
$this->initResponse();
}
public function initResponse()
{
$this->res = new Response();
return $this->res;
}
public function response($data, $code = ResponseCode::HTTP_OK, $message = ResponseCode::HTTP_OK_MESSAGE, $errorCode = 0)
{
$this->res->response($data, $code, $message, $errorCode)->send();
}
use Saidqb\CorePhp\ResponseCode;
public function __construct()
{
parent::__construct();
$this->initResponse()->hide(['password']);
}
public function index()
{
$this->response($data, ResponseCode::HTTP_OK);
}