PHP code example of vocweb / laravel-log-compress

1. Go to this page and download the library: Download vocweb/laravel-log-compress 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/ */

    

vocweb / laravel-log-compress example snippets


return [
    // Encryption password (overrides env if set)
    'password' => env('LOG_COMPRESS_PASSWORD', null),

    // Delete original log files after successful compression
    'delete_after_compress' => true,

    // Only compress logs older than N days (prevents active log compression)
    'older_than_days' => 1,

    // Automatically schedule daily compression (default: true)
    'auto_schedule' => env('LOG_COMPRESS_AUTO_SCHEDULE', true),

    // Time of day for auto-scheduled compression (24h format)
    'schedule_time' => env('LOG_COMPRESS_SCHEDULE_TIME', '00:00'),
];

protected function schedule(Schedule $schedule)
{
    $schedule->command('log:compress')->dailyAt('02:00');
}

use Illuminate\Support\Facades\Schedule;

Schedule::command('log:compress')->dailyAt('02:00');

use Illuminate\Console\Scheduling\Schedule;

->withSchedule(function (Schedule $schedule) {
    $schedule->command('log:compress')->dailyAt('02:00');
})

'channels' => [
    'daily' => [
        'driver' => 'daily',
        'path' => storage_path('logs/laravel.log'),
        'level' => env('LOG_LEVEL', 'debug'),
        'days' => 14,
    ],
    // other channels...
],
bash
php artisan vendor:publish --tag=log-compress-config
bash
php artisan log:compress
bash
php artisan log:compress --password=my_secure_password