1. Go to this page and download the library: Download thomas-squall/php-easy-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/ */
php
/**
* Class Listener.
* [\PHPEasyAPI\Server("user")] // 'user' is the endpoint
*/
class Listener
{
/**
* @param \PHPEasyAPI\Request $request
* @return string
* [\PHPEasyAPI\Enrichment\Endpoint(method = "GET", url = ":userId/getList/:listId")]
*/
public function getList($request)
{
$userId = $request["userId"];
$listId = $request["listId"];
$request->send200("List $listId of user $userId");
}
}
php
$resolver->setBaseUrl('http://localhost/MyTest'); // Assuming this is your local test url.
$resolver->bindListener(new Listener()); // 'user' is the endpoint.
php
$resolver->resolve(); // Example call: GET http://localhost/MyTest/user/10/getList/15
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.