1. Go to this page and download the library: Download jacob-roth/phapi 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/ */
jacob-roth / phapi example snippets
$Routes = new \Phapi\Routes();
$Routes->Add(new \Phapi\Route(
"Default",
"/api/v1/{controller}/{action}"
));
$Startup = new \Phapi\Startup($Routes);
$Startup->Run();
class DefaultController extends \Phapi\Controller
// This endpoint can be called like
// PUT /Default/IdPut/2
public function IdPut(int $id)
{
$this->HttpPut();
return [
"id" => $id
];
}
// This endpoint can be called like
// GET /Default/2
public function GET(int $id)
{
$this->HttpGet();
return "something";
}