1. Go to this page and download the library: Download simba/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/ */
simba / api example snippets
use simba\api\Libraries\Muzakki;
class DonationController extends BaseController
{
public function registerDonor()
{
$muzakki = new Muzakki();
$data = [
'nama' => 'John Doe',
'handphone' => '08123456789',
'email' => '[email protected]'
];
$response = $muzakki->registerDariLokal(1, $data);
return $this->response->setJSON($response);
}
}
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use simba\api\Libraries\Muzakki;
class DonationController extends Controller
{
public function registerDonor(Request $request)
{
// ✅ Direct instantiation - automatically detects Laravel Http Facade!
$muzakki = new Muzakki();
$data = [
'nama' => $request->input('nama'),
'handphone' => $request->input('handphone'),
'email' => $request->input('email')
];
$response = $muzakki->registerDariLokal(1, $data);
return response()->json($response);
}
}
public function registerDonor(Request $request)
{
// Using Laravel's service container
$muzakki = app('simba')->muzakki();
// or using Facade: $muzakki = \Simba::muzakki();
$response = $muzakki->registerDariLokal(1, $data);
return response()->json($response);
}
use simba\api\Traits\ValidationTrait;
$this->validateNik($nik); // Validate 16-digit NIK
$this->validateEmail($email); // Validate email format
$this->validatePhone($phone); // Validate phone number
$this->validateAmount($amount); // Validate amount
$this->validateDateRange($from, $to); // Validate date range
$this->validateNokk($nokk); // Validate 16-digit KK
use simba\api\Libraries\Mustahik;
$mustahik = new Mustahik();
$response = $mustahik->searchMustahik('Budi');
if ($response['success']) {
foreach ($response['data'] as $item) {
echo $item['nama'];
}
}
use simba\api\Libraries\Muzakki;
$muzakki = new Muzakki();
$response = $muzakki->getTotalDonasi('NPWZ123', 2024);
if ($response['success']) {
echo "Total: Rp " . number_format($response['data']['total']);
}