1. Go to this page and download the library: Download rootdata21/hati 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/ */
rootdata21 / hati example snippets
/*
* Register the API in the "api/hati_api_registry.php" file using
* HatiAPIHandler::register method.
*/
\hati\api\HatiAPIHandler::register([
'method' => 'GET',
'path' => 'welcome/get',
'handler' => 'v1/ExRate.php',
'description' => 'A GET API'
]);
// Use a specific database connection
Fluent::use(DBPro::exampleDb);
// search the name by id from the database table using PDO extension
$id = 5;
Fluent::exePrepared("SELECT name FROM user WHERE user.id = ?", [$id]);
// get the name value from the select statement with simple datum method
$name = Fluent::datum('name');
// craft and reply JSON output
$response = new Response();
$response -> add('name', $name);
$response -> reply('Operation has been done', header: [
'X-EXAMPLE-HEADER: SOMETHING',
'Content-Type: application/json'
]);
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.