This package was destilled from legacy code!
You better do not want it to use this in production.
$ composer require germania-kg/downloads
MySQL: This package requires some MySQL tables downloads, downloads_categories_mm and downloads_worlds_mm which you can install using germania_downloads.sql
in sql/
directory.
While the Downloads class is a simple storage, PdoDownloads reads all downloads from the database. They both implement the container-interop (upcoming PSR 11 standard), IteratorAggregate and SPL's Countable.
You can iterate over it all worlds due to its interface, and you can retrieve single Download instances:
<?php
use Germania\Downloads\Downloads;
use Germania\Downloads\PdoDownloads;
use Germania\Downloads\Download;
$downloads = new Downloads( );
$download = new Download;
$download->setUrl( 'http://...' );
$downloads->push( $download );
// Or, get all from PDO datebase:
$downloads = new PdoDownloads( $pdo );
// Check on ID and retrieve
$check = $downloads->has( 42 );
$my_download = $downloads->get( 42 );
echo $my_download->getUrl();
?>
$ git clone https://github.com/GermaniaKG/Downloads.git
$ cd Downloads
$ composer install
Either copy phpunit.xml.dist
to phpunit.xml
and adapt to your needs, or leave as is. Run PhpUnit test or composer scripts like this:
$ composer test
# or
$ vendor/bin/phpunit