1. Go to this page and download the library: Download mkd/laravel-fast-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/ */
mkd / laravel-fast-api example snippets
use MKD\FastAPI\Attributes\FastAPI;
use MKD\FastAPI\Attributes\FastAPIGroup;
#[FastAPIGroup(prefix: '/items', options: ['name' => 'items'], middlewares: ['auth'])]
class ItemsController extends Controller
{
#[FastAPI(method: FastApiMethod::GET, path: '/data/{id}', options: ['functions' => [
'whereIn' => ['id', ['2']],
], 'name' => 'item_id'])]
public function getItem($id)
{
return response()->json(['item' => $id]);
}
}
enum FastApiMethod
{
case GET;
case POST;
case PUT;
case PATCH;
case OPTION;
case DELETE;
case ANY;
case REDIRECT;
case MATCH;
}