Skip to content

Latest commit

Β 

History

History
372 lines (282 loc) Β· 8.37 KB

COMMANDS_REFERENCE.md

File metadata and controls

372 lines (282 loc) Β· 8.37 KB

πŸ› οΈ SIMBA API - COMMANDS REFERENCE

Panduan lengkap penggunaan Spark commands untuk Simba API Library.

πŸ“‹ Daftar Commands

Command Fungsi Waktu
simba:publish Publish configuration & migrations ~1s
simba:install Full setup (publish + migrate + seed) ~2-3s

πŸš€ Command 1: simba:publish

Deskripsi

Mempublikasikan file konfigurasi dan database migration files ke aplikasi Anda.

Syntax

php spark simba:publish

Yang Dilakukan

  1. βœ… Menyalin src/Config/Simba.php β†’ app/Config/Simba.php
  2. βœ… Menyalin src/Database/Migrations/* β†’ app/Database/Migrations/
  3. βœ… Otomatis menyesuaikan namespace ke aplikasi Anda
  4. βœ… Membuat direktori jika belum ada

Contoh Output

  created: Config/Simba.php
  created: Database/Migrations/2024-02-03-081118_create_config_table.php

Konfigurasi yang Dipublikasikan

File 1: Config/Simba.php

// Endpoint API
'muzakki_register'        => '/muzakki/register',
'muzakki_search'          => '/muzakki/search',
'mustahik_register'       => '/mustahik/register',
'mustahik_search'         => '/mustahik/search',
// ... dan 11 endpoint lainnya

File 2: Database/Migrations

  • 2024-02-03-081118_create_config_table.php
    • Creates table: konfigurasi
    • Columns: id, group, key, value, created_at, updated_at

Kasus Penggunaan

βœ… Fresh installation
βœ… Development setup
βœ… Ketika ingin custom configuration
βœ… Setup tanpa database seeding

Contoh Penggunaan

# Basic usage
php spark simba:publish

# Kemudian setup database manual
php spark migrate
php spark db:seed simba\\api\\Database\\Seeds\\SimbaSeeder

πŸ”§ Command 2: simba:install

Deskripsi

Setup lengkap library dalam satu command. Ini adalah rekomendasi untuk production deployment.

Syntax

php spark simba:install

Yang Dilakukan

  1. βœ… Jalankan simba:publish (publish files)
  2. βœ… Jalankan migrate (create konfigurasi table)
  3. βœ… Jalankan SimbaSeeder (insert default config)

Contoh Output

  created: Config/Simba.php
  created: Database/Migrations/2024-02-03-081118_create_config_table.php

Migration Files in Database Seeder
  [1] 2024-02-03-081118_create_config_table

Running: 2024-02-03-081118_create_config_table
  migrate  batch 1, file: 2024-02-03-081118_create_config_table

Seeding "SimbaSeeder" class
  Inserted 8 rows (4 demo + 4 production config)

Data yang Di-seed

Group: DEMO

base_url     = https://demo-simba.baznas.or.id/
org_code     = 9977200
api_key      = [base64 encoded demo key]
admin_email  = baznasprov.demo@baznas.or.id

Group: SIMBA (Production)

base_url     = https://simba.baznas.go.id/
org_code     = 3603300
api_key      = [base64 encoded production key]
admin_email  = baznas.tangerangkab@gmail.com

Error Handling

Jika ada error, command akan:

  1. βœ… Logging error ke writable/logs/
  2. βœ… Throw exception untuk debugging
  3. βœ… Menampilkan pesan error yang jelas

Contoh:

ERROR: SimbaSeeder Error: Table 'konfigurasi' doesn't exist

Kasus Penggunaan

βœ… Fresh installation
βœ… Production deployment
βœ… Setup lengkap one-go
βœ… Testing environment

Contoh Penggunaan

# Production setup (recommended)
php spark simba:install

# Konfigurasi otomatis tersedia dari database
# Menggunakan default demo account

# Update konfigurasi di .env atau database
SIMBA_BASE_URL=https://simba.baznas.go.id/
SIMBA_ORG_CODE=3603300
SIMBA_API_KEY=your_production_key

πŸ“Š Perbandingan Setup Methods

Method 1: Quick Install (Recommended)

php spark simba:install
  • βœ… Semua setup otomatis
  • βœ… Tidak ada step manual
  • ⏱️ ~2-3 detik
  • πŸ‘ Untuk production

Method 2: Step-by-Step

php spark simba:publish
php spark migrate
php spark db:seed simba\\api\\Database\\Seeds\\SimbaSeeder
  • βœ… Kontrol penuh
  • βœ… Debug lebih mudah
  • ⏱️ ~3-5 detik
  • πŸ‘ Untuk development

Method 3: Manual Import

# Import config.sql manually
# Copy files manually
# Edit composer.json autoload manually
  • βœ… Fleksibel penuh
  • ❌ Rawan error
  • ⏱️ ~5+ menit
  • πŸ‘Ž Not recommended

πŸ” Troubleshooting Commands

Issue 1: Command tidak dikenali

$ php spark simba:install
Command "simba:install" not found.

Solusi:

# Update composer autoload
composer dump-autoload

# Cek apakah library sudah terinstall
composer show simba/api

# Try again
php spark simba:install

Issue 2: Permission denied

$ php spark simba:publish
Unable to determine the correct source directory

Solusi:

# Pastikan direktori writable
chmod -R 755 writable/
chmod -R 755 app/

# Try again
php spark simba:publish

Issue 3: Table already exists

ERROR: Table 'konfigurasi' already exists

Solusi:

# Rollback migrations
php spark migrate:rollback --batch 1

# Try install again
php spark simba:install

Issue 4: Namespace error

ERROR: Class 'simba\api\Database\Seeds\SimbaSeeder' not found

Solusi:

# Update composer autoload
composer dump-autoload

# Verify file exists
ls -la src/Database/Seeds/SimbaSeeder.php

# Try again
php spark simba:install

βœ… Verification

Setelah menjalankan commands, verifikasi setup:

1. Check Config File

ls -la app/Config/Simba.php

Seharusnya ada dan readable.

2. Check Migration File

ls -la app/Database/Migrations/2024-02-03-081118_create_config_table.php

Seharusnya ada dan readable.

3. Check Database Table

php spark tinker
>>> \Config\Database::connect()->table('konfigurasi')->countAll()
// Should return 8 (4 demo + 4 production)

>>> \Config\Database::connect()->table('konfigurasi')->get()->getResult()
// Show all configuration records

4. Test in Controller

<?php

namespace App\Controllers;

use simba\api\Services\ConfigService;

class TestController extends BaseController
{
    public function testConfig()
    {
        $baseUrl = ConfigService::get('demo', 'base_url');
        dd($baseUrl); // Should show: https://demo-simba.baznas.or.id/
    }
}

🎯 Recommended Setup Flow

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ 1. composer require simba/api   β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
             ↓
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ 2. php spark simba:install      β”‚
β”‚    (Do everything at once!)     β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
             ↓
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ 3. php spark tinker             β”‚
β”‚    (Verify in database)         β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
             ↓
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ 4. Update .env config           β”‚
β”‚    (Set production credentials) β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
             ↓
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ 5. Start using library!         β”‚
β”‚    (Ready for production!)      β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

πŸ“š Related Documentation


πŸ’‘ Tips & Best Practices

  1. Always use simba:install untuk production - Lebih aman dan terjamin
  2. Run php spark list | grep simba - Untuk lihat available commands
  3. Check logs di writable/logs/ - Jika ada error
  4. Backup database - Sebelum rollback migrations
  5. Update composer regularly - Untuk latest version

πŸ“ž Support

Questions or issues? Contact: rifacomputerlampung@gmail.com


Version: 2.0.0
Last Updated: November 2025
Status: βœ… Production Ready