SQL
This example demonstrates connecting to an external MySQL database and syncing two different tables (users and orders) from that single source.
use Andach\ExtractAndTransform\Facades\ExtractAndTransform;
// 1. Create the Source (Connection) once
$dbSource = ExtractAndTransform::createSource('Legacy DB', 'sql', [
'driver' => 'mysql',
'host' => '192.168.1.50',
'database' => 'legacy_app',
'username' => 'readonly_user',
'password' => 'secret',
]);
// 2. Sync the 'users' table
$dbSource->sync('users')
->withStrategy('full_refresh')
->toTable('legacy_users')
->run();
// 3. Sync the 'orders' table
$dbSource->sync('orders')
->withStrategy('full_refresh')
->mapColumns(['order_id' => 'id', 'total_amount' => 'amount'])
->toTable('legacy_orders')
->run();