axel-php/axel

Accelerated file downloads in PHP using Axel

0.0.13 2015-06-06 22:35 UTC

This package is not auto-updated.

Last update: 2024-11-09 18:22:10 UTC


README

Codeship Status for ianoshorty/axel-php Code Climate Latest Stable Version Total Downloads Latest Unstable Version License

General

The AXEL-PHP library wraps around the C based Axel library. Axel performs accelerated downloads from the command line, similar to wget.

AXEL-PHP offers asynchronous and synchronous downloads. See below for usage.

AXEL-PHP also comes with an optional FIFO download manager with the ability to set numbers of current downloads. Just implement AxelDownloadManagerQueueInterface together with your favourite queuing service.

** PLEASE NOTE: This library is under active development as an alpha and is subject to change at any time. **

Example Usages

Sync Download With Complete Callback

$axel = new Axel\AxelDownload();
$axel->start('http://www.google.com', null, null, function($axel, $status, $success, $error) {
    echo 'File Downloaded';
    print_r($status);
});

Start Async Download

$axel = new Axel\AxelDownload();
$axel->startAsync('http://ipv4.download.thinkbroadband.com/1GB.zip', 'test.zip', '~/');

Start Async Download With Progress Callbacks

$axel = new Axel\AxelDownload();
$axel->startAsync('http://ipv4.download.thinkbroadband.com/1GB.zip', 'test.zip', '~/', function($axel, $status, $success, $error) {
   echo 'Progress updated';
   print_r($status);
});

Setup Download / Delayed Start

$axel = new Axel\AxelDownload();
$axel->addDownloadParameters([
    'address'           => 'http://www.google.com',
    'filename'          => 'test.html',
    'download-path'     => '~/',
    'callback'          => function($axel, $status, $success, $error) {
        echo 'Progress updated';
        print_r($status);
    }
]);
$axel->startAsync();

Get Download Status

$status = $axel->updateStatus();

Cleanup

$axel->clearCompleted()

Axel Managed Download Queue (Synchronous)

$dm = new Axel\AxelDownloadManager(new AxelDownloadManagerSyncQueue(), 'axel');
$dm->queueDownload('http://www.google.com', 'file1.html');
$dm->queueDownload('http://www.yahoo.com', 'file2.html');
$dm->processQueue();

Version

0.0.13

Installation

Prerequesites

In order to install RPVR you will need:

  • PHP 5.4 or higher
  • Axel - A linux server with Axel installed

Install Instructions

The preferred method of installation is via Composer and Packagist.

  1. Install the axel command-line tool on the target system - $ sudo apt-get install axel
  2. Install the AXEL-PHP library - $ composer require axel-php/axel

Development

Want to contribute? Great! Feel free to get in touch with me and we can collaborate, or fork / pull as you like.

TODO

  • Possible log options / write to log file?
  • Intelligently deal with both concurrent connections and concurrent downloads
  • Check write permissions in download directory
  • Pause queue (Maybe subclass?)
  • Test queue Async

License

The MIT License (MIT)

Copyright (c) 2015 Ian Outterside (Ian Builds Apps).

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.