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')
->setPathPrefix('_api/v2')
->setController(ProductController::class)
->setMethod('check')
->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::newApi('public')
->setController(ProductController::class)
->setMethod('publicInfo')
->setRequestMethod('GET')
->setAuthType(AuthType::NONE);
// Create a protected API endpoint with Bearer token authentication
Api::newApi('protected')
->setController(ProductController::class)
->setMethod('secureData')
->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.