1. Go to this page and download the library: Download otlib/rest-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/ */
ext_localconf.php
__________________
use Otlib\RestApi\Api;
use Otlib\RestApi\Enumeration\AuthType;
use YourExtension\Controller\ProductController;
Api::newApi('check-product-status')
->setPathPrefix('_api/v2')
->setController(ProductController::class)
->setMethod('checkProductStatus')
->setAuthType(AuthType::BEARER)
->setRequestMethod('POST')
->setHeaderWithNoCache(true);
use Otlib\RestApi\Api;
use Otlib\RestApi\Enumeration\AuthType;
Api::newApi('secure-endpoint')->setAuthType(AuthType::BEARER) ...;
ext_localconf.php
__________________
use Otlib\RestApi\Api;
use Otlib\RestApi\Enumeration\AuthType;
use YourExtension\Controller\ProductController;
// Create a public API endpoint (/api/product-info) -> (ProductController::class)->getProductInfo(ServerRequestInterface $request)
Api::newApi('product-info')
->setController(ProductController::class)
->setMethod('getProductInfo')
->setRequestMethod('GET')
->setAuthType(AuthType::NONE);
// Create a protected API endpoint with Bearer token authentication (/api/product-info) -> (ProductController::class)->getProductInfo(ServerRequestInterface $request)
Api::newApi('product-info')
->setController(ProductController::class)
->setMethod('getProductInfo')
->setRequestMethod('POST')
->setAuthType(AuthType::BEARER)
->setHeaderWithNoCache(true);
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.