Pustaka (library) ini menyediakan cara mudah untuk berinteraksi dengan API Simba BAZNAS RI di dalam aplikasi CodeIgniter 4 dan Laravel.
β¨ Latest in v2.1.0: Full Laravel support with auto-detection HTTP client, enhanced error handling, and comprehensive integration guide!
composer require simba/apiSIMBA_BASE_URL=https://demo-simba.baznas.or.id/
SIMBA_ORG_CODE=9977200
SIMBA_API_KEY=your_api_key
SIMBA_ADMIN_EMAIL=admin@example.com<?php
use simba\api\Libraries\Muzakki;
class DonationController extends BaseController
{
public function registerDonor()
{
$muzakki = new Muzakki();
$data = [
'nama' => 'John Doe',
'handphone' => '08123456789',
'email' => 'john@example.com'
];
$response = $muzakki->registerDariLokal(1, $data);
return $this->response->setJSON($response);
}
}<?php
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);
}
}# 1. Install
composer require simba/api
# 2. Configure `.env`
SIMBA_BASE_URL=https://demo-simba.baznas.or.id/
SIMBA_ORG_CODE=9977200
SIMBA_API_KEY=your_api_key
SIMBA_ADMIN_EMAIL=admin@example.com
# 3. (Optional) Publish configuration
php artisan vendor:publish --provider="simba\api\Laravel\SimbaServiceProvider"
# 4. Start using!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);
}π Complete Laravel Integration Guide: See LARAVEL_INTEGRATION_GUIDE.md
| Library | Purpose |
|---|---|
| Muzakki | Donatur (Muzakki) Management |
| Mustahik | Penerima Manfaat (Mustahik) Management |
| Pengumpulan | Pengumpulan (Inbound Transaction) |
| Penyaluran | Penyaluran (Outbound Transaction) |
| Upz | UPZ (Unit Pengumpul Zakat) Management |
β
Auto-Detecting HTTP Client - Automatically selects Laravel Http Facade or CodeIgniter Services
β
Laravel Integration - Works seamlessly with Laravel 8+
β
CodeIgniter Support - Full CodeIgniter 4 compatibility
β
Response Formatter - Consistent response format
β
Validation Trait - Reusable validation logic
β
Exception Handling - Custom exception classes
β
Service Provider - Easy dependency injection
β
Type Hints - Full type-safe methods
β
Error Logging - Built-in error tracking
β
PSR-4 Autoloading - Modern PHP standards
{
"success": true,
"status_code": 200,
"message": "Success",
"data": { /* API 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 KKsrc/
βββ Client.php # Base HTTP Client (Auto-detecting)
βββ ServiceProvider.php # Service registration
βββ Commands/
β βββ InstallCommand.php # CLI install command
β βββ PublishCommand.php # CLI publish command
βββ Exceptions/
β βββ SimbaApiException.php # Custom exceptions
βββ Libraries/
β βββ Muzakki.php # Donatur management
β βββ Mustahik.php # Recipient management
β βββ Pengumpulan.php # Inbound transactions
β βββ Penyaluran.php # Outbound transactions
β βββ Upz.php # UPZ management
βββ Services/
β βββ ResponseFormatter.php # Response formatting
β βββ ConfigService.php # Configuration service
β βββ Laravel/ # Laravel integration
β βββ Manager.php # Service manager
β βββ Facade.php # Facade class
β βββ SimbaServiceProvider.php
βββ Traits/
β βββ ValidationTrait.php # Reusable validations
βββ Models/
β βββ ApiModel.php # Database model
βββ Config/
βββ Simba.php # Main configuration
php spark simba:publishThis command publishes the configuration and migration files to your application:
- Copies
Config/Simba.phptoapp/Config/Simba.php - Copies migrations to
app/Database/Migrations/
php spark simba:installThis command performs complete setup:
- Publishes configuration and migration files
- Runs all pending migrations
- Seeds default configuration data
Output:
created: Config/Simba.php
created: Database/Migrations/2024-02-03-081118_create_config_table.php
Migration complete
Seeding data...
# 1. Publish files
php spark simba:publish
# 2. Setup database (includes migrations + seeding)
php spark simba:installuse simba\api\Libraries\Muzakki;
$muzakki = new Muzakki();
$response = $muzakki->registerDariLokal(1, [
'nama' => 'Andi Wijaya',
'handphone' => '08123456789',
'nik' => '1234567890123456',
'email' => 'andi@example.com'
]);
if ($response['success']) {
echo "NPWZ: " . $response['data']['npwz'];
}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']);
}use simba\api\Libraries\Pengumpulan;
$pengumpulan = new Pengumpulan();
$response = $pengumpulan->transaksiDariLokal(1, [
'subjek' => 'NPWZ123',
'tanggal' => '2024-01-15',
'program' => 'PROGRAM001',
'via' => 'VIA001',
'akun' => 'AKUN001',
'jumlah' => 500000
]);use simba\api\Libraries\Penyaluran;
$penyaluran = new Penyaluran();
$response = $penyaluran->simpanTransaksi([
'subjek' => 'NRM123', // Mustahik ID
'tanggal' => '2024-01-15',
'program' => '211010000', // Konsumtif
'via' => '11010101', // Transfer Bank
'akun' => '51010203', // Zakat
'jumlah' => 750000
]);- β All files syntax validated
- β Type-safe methods
- β Error handling implemented
- β Security best practices
- β Comprehensive documentation
- β Extensible architecture
For complete documentation and guides:
- π LARAVEL_INTEGRATION_GUIDE.md β - Complete Laravel integration guide with examples
- π LARAVEL_READY.md - Quick start checklist
- π DOCUMENTATION.md - Full API reference
- π INSTALLATION.md - Installation instructions
- π PERBAIKAN_SUMMARY.md - Changes summary
The library automatically detects and selects the appropriate HTTP client:
- Laravel Http Facade (Laravel 8+) β Preferred in Laravel
- CodeIgniter Services (CodeIgniter 4) β Preferred in CodeIgniter
- PHP cURL Extension β Fallback
- Custom HTTP Client β If injected
No manual configuration needed! π―
For issues or questions:
- π§ Email: rifacomputerlampung@gmail.com
- π Documentation: See LARAVEL_INTEGRATION_GUIDE.md for troubleshooting
MIT License - See license.md for details
Version: 2.1.0
Last Updated: November 2025
Status: β
Production Ready
Frameworks Tested: CodeIgniter 4 β
| Laravel 8+ β