Skip to main content

(English)

Part 2: Developer Guide

This section provides a technical overview for developers on how to set up, use, and extend the ETL service.

1. Setup and Configuration

  1. Create a Schema File: In config/etl_schemas/, create a .yml file for your model (e.g., user_schema.yml). This is the most critical step.
  2. Register Service Provider: Ensure App\Providers\EtlServiceProvider::class is in the providers array in config/app.php.
  3. Register Facade Alias: In config/app.php, add 'Etl' => App\Services\Etl\Etl::class, to the aliases array.
  4. Clear Cache: Run php artisan config:clear.

2. Schema Preparation

The schema file is the single source of truth. Below is a reference for its properties.

3. Core Usage: Calling the Service

Importing Data Typically done in a controller method.
Exporting Data (Fluent API) The export() method provides a clean, chainable interface.
  • Basic Export:
  • Advanced Export (Filtered, Paginated, Different Driver & Disk):

4. Advanced Usage: Leveraging the Schema

Your SchemaService can be used to drive other parts of your application.
  • Validation in a Form Request:
  • API Resources:

5. Testing

Use the built-in Artisan command to test the entire pipeline without a browser.

For Developers: How to Call the CSV Driver

To process a CSV file, simply call the open_spout_csv_schema_import driver. English Example:

(Bahasa Indonesia)

Bagian 2: Panduan Developer

Bagian ini menyediakan gambaran teknis bagi developer tentang cara mengatur, menggunakan, dan mengembangkan layanan ETL.

1. Pengaturan dan Konfigurasi

  1. Buat File Skema: Di dalam config/etl_schemas/, buat sebuah file .yml untuk model Anda (contoh: user_schema.yml). Ini adalah langkah paling krusial.
  2. Daftarkan Service Provider: Pastikan App\Providers\EtlServiceProvider::class ada di dalam array providers di config/app.php.
  3. Daftarkan Alias Facade: Di config/app.php, tambahkan 'Etl' => App\Services\Etl\Etl::class, ke dalam array aliases.
  4. Hapus Cache: Jalankan php artisan config:clear.

2. Persiapan Skema

File skema adalah satu-satunya sumber kebenaran (single source of truth). Berikut adalah referensi untuk propertinya.

3. Penggunaan Inti: Memanggil Layanan

Mengimpor Data Biasanya dilakukan di dalam method controller.
Mengekspor Data (API Fluent) Method export() menyediakan antarmuka yang bersih dan dapat dirangkai (chainable).
  • Ekspor Dasar:
  • Ekspor Lanjutan (Difilter, Dipaginasi, Driver & Disk Berbeda):

4. Penggunaan Lanjutan: Memanfaatkan Skema

SchemaService Anda dapat digunakan untuk menggerakkan bagian lain dari aplikasi Anda.
  • Validasi di Form Request:
  • API Resources:

5. Pengujian

Gunakan perintah Artisan bawaan untuk menguji seluruh alur proses tanpa memerlukan browser.

Untuk Pengguna: Format File CSV

Selain Excel (.xlsx), layanan ini juga dapat mengimpor data dari file Comma-Separated Value (.csv).
  • Baris pertama harus berupa baris header (judul kolom).
  • Baris anak (misalnya, alamat kedua untuk seorang pengguna) dibuat dengan menambahkan baris baru di mana kolom-kolom induk dibiarkan kosong. Dalam file CSV, ini berarti memulai baris dengan tanda koma.
Contoh users.csv:
Perhatikan bagaimana baris kedua dimulai dengan tiga koma , ,, untuk melewati kolom User ID, Nama Lengkap, dan Alamat Email, yang menandakan baris tersebut adalah alamat lain milik Budi Santoso.
Contoh Bahasa Indonesia: