(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
- Create a Schema File: In
config/etl_schemas/, create a.ymlfile for your model (e.g.,user_schema.yml). This is the most critical step. - Register Service Provider: Ensure
App\Providers\EtlServiceProvider::classis in theprovidersarray inconfig/app.php. - Register Facade Alias: In
config/app.php, add'Etl' => App\Services\Etl\Etl::class,to thealiasesarray. - 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.export() method provides a clean, chainable interface.
- Basic Export:
- Advanced Export (Filtered, Paginated, Different Driver & Disk):
4. Advanced Usage: Leveraging the Schema
YourSchemaService 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 theopen_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
- Buat File Skema: Di dalam
config/etl_schemas/, buat sebuah file.ymluntuk model Anda (contoh:user_schema.yml). Ini adalah langkah paling krusial. - Daftarkan Service Provider: Pastikan
App\Providers\EtlServiceProvider::classada di dalam arrayprovidersdiconfig/app.php. - Daftarkan Alias Facade: Di
config/app.php, tambahkan'Etl' => App\Services\Etl\Etl::class,ke dalam arrayaliases. - 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.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.
users.csv:
, ,, untuk melewati kolom User ID, Nama Lengkap, dan Alamat Email, yang menandakan baris tersebut adalah alamat lain milik Budi Santoso.
Contoh Bahasa Indonesia:
