PHPackages                             coderden/file-downloader - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [File &amp; Storage](/categories/file-storage)
4. /
5. coderden/file-downloader

ActiveLibrary[File &amp; Storage](/categories/file-storage)

coderden/file-downloader
========================

Professional file downloader package for PHP with helper functions

1.0.0(5mo ago)03MITPHPPHP ^8.0

Since Jan 18Pushed 5mo agoCompare

[ Source](https://github.com/dnsinyukov/file-downloader)[ Packagist](https://packagist.org/packages/coderden/file-downloader)[ RSS](/packages/coderden-file-downloader/feed)WikiDiscussions main Synced today

READMEChangelog (1)Dependencies (1)Versions (2)Used By (0)

File Downloader
===============

[](#file-downloader)

A professional PHP library for downloading files with support for HTTP, HTTPS, FTP, local files, and parallel downloads.

Features
--------

[](#features)

- ✅ Multi-protocol support (HTTP, HTTPS, FTP, local files)
- ✅ Chunked streaming for large file downloads
- ✅ Asynchronous and parallel downloads
- ✅ Built-in image and file type processing
- ✅ Validation system (size, MIME type, extension)
- ✅ Guzzle HTTP Client integration
- ✅ Extensible architecture
- ✅ PHP 8.0+

Installation
------------

[](#installation)

```
composer require coderden/file-downloader
```

Quick Start
-----------

[](#quick-start)

### Simple File Download

[](#simple-file-download)

```
// Initialization (optional)
FileDownloadHelper::init([
    'default_destination' => __DIR__ . '/downloads',
    'timeout' => 60,
]);

// Download single file
$result = FileDownloadHelper::download('https://example.com/image.jpg');

// Quick download with auto-generated filename
$filePath = FileDownloadHelper::quickDownload('https://example.com/file.pdf');

// Download multiple files
$results = FileDownloadHelper::downloadMultiple([
    'https://example.com/file1.jpg',
    'https://example.com/file2.png',
    'ftp://user:pass@example.com/file3.zip',
]);
```

### Using Builder Pattern

[](#using-builder-pattern)

```
use CodeDen\FileDownloader\DownloadBuilder;

$result = (new DownloadBuilder())
    ->from('https://example.com/large-file.zip')
    ->to('/path/to/downloads')
    ->chunked(true)
    ->chunkSize(2 * 1024 * 1024) // 2MB chunks
    ->maxSize(500 * 1024 * 1024) // 500MB max
    ->download();
```

Core Features
-------------

[](#core-features)

### Multi-Protocol Support

[](#multi-protocol-support)

```
// HTTP/HTTPS
FileDownloadHelper::download('https://example.com/file.jpg');

// FTP
FileDownloadHelper::downloadViaFtp(
    'ftp://username:password@example.com/path/to/file.zip',
    __DIR__ . '/downloads/file.zip',
    [
        'port' => 21,
        'timeout' => 30,
    ]
);

// Local files (copying)
FileDownloadHelper::download('file:///path/to/local/file.txt');
```

### Large File Downloads

[](#large-file-downloads)

```
// Chunked streaming download
$result = FileDownloadHelper::downloadLargeFile(
    'https://example.com/ubuntu-22.04.iso',
    __DIR__ . '/downloads/ubuntu.iso',
    5 * 1024 * 1024, // 5MB chunks
    function ($downloaded, $total) {
        $percent = $total > 0 ? ($downloaded / $total) * 100 : 0;
        echo "Downloaded: " . round($percent, 2) . "%\n";
    }
);
```

### Parallel Downloads

[](#parallel-downloads)

```
// Asynchronous multiple file download
$results = FileDownloadHelper::downloadParallel(
    [
        'https://example.com/file1.jpg',
        'https://example.com/file2.jpg',
        'https://example.com/file3.jpg',
    ],
    __DIR__ . '/downloads',
    3 // 3 concurrent downloads
);

// Download with rate limiting
$results = FileDownloadHelper::downloadWithRateLimit(
    $urls,
    __DIR__ . '/downloads',
    2 // 2 requests per second
);
```

### File Validation

[](#file-validation)

```
$manager = new FileDownloadManager();
$manager->addValidator(new SizeValidator(10 * 1024 * 1024)); // 10MB max
$manager->addValidator(new MimeTypeValidator(['image/jpeg', 'image/png']));

$result = (new DownloadBuilder($manager))
    ->from('https://example.com/image.jpg')
    ->to(__DIR__ . '/downloads')
    ->download();
```

Advanced Usage
--------------

[](#advanced-usage)

### Custom Downloader

[](#custom-downloader)

```
class S3Downloader implements DownloaderInterface
{
    public function download(string $source, string $destination): bool
    {
        // Implement S3 download logic
        return true;
    }

    public function supports(string $protocol): bool
    {
        return str_starts_with($protocol, 's3://');
    }

    public function setOptions(array $options): void
    {
        // Configure options
    }
}

// Usage
$manager = new FileDownloadManager();
$manager->addDownloader(new S3Downloader());
```

### Custom Validator

[](#custom-validator)

```
use CodeDen\FileDownloader\Contracts\ValidatorInterface;

class VirusScannerValidator implements ValidatorInterface
{
    public function validate(string $filePath): bool
    {
        // Scan file for viruses
        return $this->scanForViruses($filePath);
    }

    public function getErrorMessage(): string
    {
        return 'File contains viruses';
    }
}
```

Configuration
-------------

[](#configuration)

### Global Configuration

[](#global-configuration)

```
// config/downloader.php
return [
    'defaults' => [
        'destination' => storage_path('downloads'),
        'timeout' => 60,
        'chunk_size' => 1048576, // 1MB
        'max_file_size' => 1073741824, // 1GB
        'allowed_extensions' => [
            'jpg', 'jpeg', 'png', 'gif', 'pdf', 'zip', 'txt'
        ],
    ],
    'ftp' => [
        'default_port' => 21,
        'timeout' => 30,
        'passive_mode' => true,
    ],
    'http' => [
        'timeout' => 30,
        'connect_timeout' => 10,
        'verify_ssl' => true,
        'follow_redirects' => true,
        'headers' => [
            'User-Agent' => 'CodeDen-FileDownloader/1.0',
        ],
    ],
    'events' => [
        'enabled' => true,
        'progress_interval' => 5, // seconds
    ],
    'retry' => [
        'max_attempts' => 3,
        'delay' => 1000, // milliseconds
    ]
];
```

### Initialization with Configuration

[](#initialization-with-configuration)

```
FileDownloadHelper::init(include 'config/downloader.php');
```

### DownloadBuilder (Fluent Interface)

[](#downloadbuilder-fluent-interface)

```
$builder = new DownloadBuilder()
    ->from($url)                    // Source (string or array)
    ->to($destination)              // Destination directory
    ->withOptions($options)         // Options
    ->chunked(true)                 // Enable chunked download
    ->chunkSize($bytes)             // Chunk size
    ->maxSize($bytes)               // Maximum file size
    ->timeout($seconds)             // Timeout
    ->download();                   // Execute download
```

### FileDownloadManager

[](#filedownloadmanager)

Main class for managing downloads with custom component support.

```
$manager = new FileDownloadManager();
$manager->addDownloader(new CustomDownloader());
$manager->addValidator(new CustomValidator());
```

Error Handling
--------------

[](#error-handling)

```
try {
    $result = FileDownloadHelper::download('https://example.com/file.jpg');
} catch (DownloadFailedException $e) {
    echo "Download error: " . $e->getMessage();
} catch (ValidationFailedException $e) {
    echo "Validation error: " . $e->getMessage();
}
```

Examples
--------

[](#examples)

### Bulk Download with Limits

[](#bulk-download-with-limits)

```
// Download 100 files with 5 concurrent limit
$urls = [/* array of 100 URLs */];

$results = FileDownloadHelper::batchDownload(
    $urls,
    __DIR__ . '/downloads/gallery',
    5, // concurrency
    function ($completed, $total) {
        echo "Completed: {$completed}/{$total}\n";
    }
);
```

### Framework Integration

[](#framework-integration)

```
// Laravel Service Provider
namespace App\Providers;

use CodeDen\FileDownloader\FileDownloadManager;
use Illuminate\Support\ServiceProvider;

class FileDownloadServiceProvider extends ServiceProvider
{
    public function register()
    {
        $this->app->singleton(FileDownloadManager::class, function ($app) {
            $manager = new FileDownloadManager();

            // Configuration from config/filesystems.php
            $config = $app['config']['filesystems.disks'];

            // Add custom downloaders
            foreach ($config['downloaders'] ?? [] as $downloader) {
                $manager->addDownloader(new $downloader());
            }

            return $manager;
        });
    }
}
```

###  Health Score

32

—

LowBetter than 69% of packages

Maintenance71

Regular maintenance activity

Popularity3

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity40

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

165d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/19547875?v=4)[Denis Sinyukov](/maintainers/dnsinyukov)[@dnsinyukov](https://github.com/dnsinyukov)

---

Top Contributors

[![dnsinyukov](https://avatars.githubusercontent.com/u/19547875?v=4)](https://github.com/dnsinyukov "dnsinyukov (4 commits)")

### Embed Badge

![Health badge](/badges/coderden-file-downloader/health.svg)

```
[![Health](https://phpackages.com/badges/coderden-file-downloader/health.svg)](https://phpackages.com/packages/coderden-file-downloader)
```

###  Alternatives

[aws/aws-sdk-php

AWS SDK for PHP - Use Amazon Web Services in your PHP project

6.3k543.5M2.6k](/packages/aws-aws-sdk-php)[google/cloud

Google Cloud Client Library

1.2k16.7M57](/packages/google-cloud)[neuron-core/neuron-ai

The PHP Agentic Framework.

2.0k656.1k38](/packages/neuron-core-neuron-ai)[tencentcloud/tencentcloud-sdk-php

TencentCloudApi php sdk

3741.3M47](/packages/tencentcloud-tencentcloud-sdk-php)[tempest/framework

The PHP framework that gets out of your way.

2.2k34.4k15](/packages/tempest-framework)[eslazarev/wildberries-sdk

Wildberries OpenAPI clients (generated).

273.0k](/packages/eslazarev-wildberries-sdk)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
