PHP code example of xve / laravel-db-export

1. Go to this page and download the library: Download xve/laravel-db-export library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

xve / laravel-db-export example snippets


'mysql_options' => [
    'dump_binary_path' => env('DB_EXPORT_DUMP_BINARY_PATH'),
    // ...
],

'mysql_options' => [
    'set_gtid_purged' => null,      // MySQL-only
    'column_statistics' => null,     // MySQL 8+ only
],

'cleanup' => [
    'enabled' => true,
    'keep_recent' => 0,  // 0 = delete all, or set number to keep
],

'profiles' => [
    'my-profile' => [
        'description' => 'My custom export profile',
        'exclude' => [
            'telescope_*',
            '*_logs',
        ],
        'structure_only' => [
            'audits',
            'activity_log',
        ],
        '

'anonymize' => [
    'users' => [
        // Faker - generate fake data (or fallback if faker not installed)
        'name' => ['strategy' => 'faker', 'method' => 'name'],
        'email' => ['strategy' => 'faker', 'method' => 'safeEmail'],
        'phone' => ['strategy' => 'faker', 'method' => 'phoneNumber'],

        // Hash - bcrypt hash a value
        'password' => ['strategy' => 'hash', 'value' => 'password'],

        // Mask - partially hide value
        'credit_card' => ['strategy' => 'mask', 'keep_last' => 4],

        // Null - set to null
        'remember_token' => ['strategy' => 'null'],

        // Fixed - set to specific value
        'status' => ['strategy' => 'fixed', 'value' => 'active'],
    ],
],

// config/db-export.php
'preserve_rows' => [
    'users' => [
        'column' => 'email',
        'domains' => ['xve.be', 'company.com'],
    ],
    'customers' => [
        'column' => 'contact_email',
        'domains' => ['xve.be'],
    ],
],

   'structure_only' => ['audits', 'activity_log'],
   
bash
php artisan vendor:publish --tag=db-export-config
bash
php artisan db:export:setup
bash
php artisan db:export:list-profiles
php artisan db:export:list-profiles --detailed
bash
php artisan db:export:estimate
php artisan db:export:estimate --detailed
bash
# Export with default profile
php artisan db:export

# Skip confirmation prompt
php artisan db:export --force

# Dry run (show what would be exported)
php artisan db:export --dry-run

# Export only telescope/audits for debugging
php artisan db:export --profile=inspection
bash
php artisan db:export:prune
bash
php artisan db:export --force
bash
php artisan db:export --
bash
php artisan db:export --profile=inspection --force
bash
php artisan db:export --structure-only="*" --force
bash
   php artisan db:export --connection=replica