1. Go to this page and download the library: Download imamnc/efihub-client 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/ */
use Efihub\EfihubClient;
class UserService
{
public function __construct(private EfihubClient $efihub)
{
}
public function getAllUsers()
{
$response = $this->efihub->get('/users');
if ($response->successful()) {
return $response->json();
}
throw new Exception('Failed to fetch users');
}
}
$response = Efihub::get('/users');
// Check if successful
if ($response->successful()) {
$data = $response->json();
$status = $response->status();
}
// Handle errors
if ($response->failed()) {
$error = $response->json();
Log::error('EFIHUB API Error', $error);
}