PHP code example of ringlesoft / db-archive

1. Go to this page and download the library: Download ringlesoft/db-archive 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/ */

    

ringlesoft / db-archive example snippets


protected function schedule(Schedule $schedule)
{
    $schedule->command('db-archive:archive')->dailyAt('01:00'); // Run daily at 1:00 AM
}


'connection' => 'mysql_archive',
...
'tables' => [
    'orders',
    'comments'
],

'connection' => 'mysql_archive',
...
'tables' => [
    'orders' => [
        'archive_older_than_days' => 90, // Archive orders older than 90 days
        'date_column' => 'order_date',   // Use 'order_date' column for age check
        'batch_size' => 5000,            // Process in batches of 5000
        'conditions' => [                 // Additional conditions
            ['status', '=', 'completed'],
        ],
    ],
];
bash
php artisan vendor:publish --provider="RingleSoft\DbArchive\DbArchiveServiceProvider" --tag="config"
bash
php artisan db-archive:setup
bash
php artisan queue:table
php artisan migrate
bash
php artisan queue:batches-table
php artisan migrate
bash
php artisan db-archive:archive