PHP code example of think.studio / laravel-download-util

1. Go to this page and download the library: Download think.studio/laravel-download-util 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/ */

    

think.studio / laravel-download-util example snippets


$storage = Storage::disk('my-disk');

$zipFileName = (new ZipArchiver($storage))
            ->setArchiveCreationCallback(function ($archive, $files,) {
                foreach ($files as $directory => $filesList) {
                    foreach ($filesList as $fileName => $file) {
                        $archive->addFile($file, "{$directory}/".Str::afterLast($fileName, '/'));
                    }
                }
            })->create($files, "app/assets-".Carbon::now()->format('Y-m-d-his'));

if($zipFileName) {
    return $storage->url($zipFileName)''
}

$schedule->command('download-util:prune-outdated prunable_downloads -S 36000 -E ".zip"')->everyThirtyMinutes();
shell
php artisan vendor:publish --provider="LaravelDownloadUtil\ServiceProvider" --tag="config"