1. Go to this page and download the library: Download stonedz/pff2-rest 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/ */
namespace pff\controllers;
use pff\Abs\AController;
use pff\modules\Iface\IRestController;
class Api1_Users_Controller extends AController implements IRestController
{
public function getHandler()
{
echo json_encode(['ok' => true, 'method' => 'GET']);
}
public function postHandler()
{
echo json_encode(['ok' => true, 'method' => 'POST']);
}
public function putHandler()
{
echo json_encode(['ok' => true, 'method' => 'PUT']);
}
public function deleteHandler()
{
echo json_encode(['ok' => true, 'method' => 'DELETE']);
}
}
authorize(IController $controller)
namespace pff\models;
use pff\Iface\IController;
use pff\modules\Iface\IRestAuth;
use pff\modules\Exception\RestException;
class ApiAuthCkecker implements IRestAuth
{
public function authorize(IController $controller)
{
$token = $_SERVER['HTTP_AUTHORIZATION'] ?? '';
if ($token === '') {
throw new RestException('Unauthorized', 401);
}
}
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.