PHP code example of objective-php / rest-action
1. Go to this page and download the library: Download objective-php/rest-action 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/ */
objective-php / rest-action example snippets
$action = new RestAction();
/*
* Assume our RestAction has `application/xml` and `application/json` available
* as media types, in order of highest-to-lowest preference for delivery
*/
$action->registerSerializer('application/*json', JsonSerializer::class);
/*
* Assume our RestAction has two Endpoints version available with
* requests like `https://api.example/users` with `API-VERSION:1.0.0` or `API-VERSION:2.0.0` header
*
* Note that it support Semver matching, so the resource is also available with
* requests like `https://api.example/users` with `API-VERSION:1` or `API-VERSION:2` header
*/
$action->registerEndpoint('1.0.0', UsersEndpointV1::class);
$action->registerEndpoint('2.0.0', UsersEndpointV2::class);