Proof of concept Laravel app for downloading remote resources, using Jobs and tracking progress.
This application lets you add a file to the download queue.
Only certain file formats are allowed. Defaults: pdf,zip,rar,7zip,tar,gz,doc,docx,mp3,wav,avi,png,jpg,jpeg,webp,txt,rtf,sql
.
- The user adds a valid link to a file for download.
- The information is written in the database, storing the URL, file name, format and status (
Pending
by default) in the form of aDownload
object (represented by aDownload
model). - A Job is dispatched to the queue and will be processed by the workers.
- When the job begins, the file will be put into
Downloading
status. - If the Job fails, then the
Download
object status will be changed toError
- If the Job succeeds, then the
Download
object status will be changed toComplete
- If the
Download
object hasComplete
status, then it can be downloaded.
Adding and listing queued downloads can be done either from the REST API (see docs), Web frontend or CLI (see CLI docs).
File download can be done only via REST API or Web frontend.
PHP 8.1
Composer v2
- Clone the repo locally
- Edit
.env
with your DB credentials,APP_KEY
,APP_URL
,ADPLEXITY_ALLOWED_FORMATS
. - Run
./prepare.sh
. This script will fetch the latest files from the repository, clear cache, run migrations and install composer dependencies. - Run
php artisan serve
to start the app. - [Optional] To generate API docs - run
php ./generate_apidoc.php
. [apidoc
andnodejs
are required!!!. Also you won't be able to view documentation, usingphp artisan serve
. You need to open it on the app's domain.] - The application does not include any demo data by default.
In order to start the workers, simply run ./work_queues.sh
.
The application is fully localised and can be easily translated to other languages.
The application comes with a CLI command for monitoring and adding new downloads to the queue.
php artisan downloads
-> (Defaults to the help
action)
php artisan downloads help
-> Prints a table with a list of available actions and descriptions.
php artisan downloads index
-> Will print a table, listing all queued downloads with their status and other useful data.
php artisan downloads store https://URL_TO_FILE_TO_DOWNLOAD
-> Adds a file to the download queue and if OK -> will display the index table.
Documentation for the API can be found under /docs
in your app URL.
Example for the hosted demo: https://adplexity-laravel.drpanchev.com/docs
Run the following commands for tests:
- Run
php artisan test
- Note: the application is missing
feature
tests, because they were not part of the task, but might be added in the incoming days, because it's fun to write them.
You can see a demo of the app here: https://adplexity-laravel.drpanchev.com/
Because the application here runs on a shared hosting, jobs are not operational. The only available functionality for testing is adding a new file for downloads and listing them. Using the sync
driver for processing the queue would make the web app slow, so it's not in use.
- Better error handler.
- Search / pagination / filtering / sorting of the listings for both API and Web.
- Update / Delete of links.
- Add support for RabbitMQ as queue driver.
- Add configurable limitations for downloadable file sizes.
app/Console/Commands
app/Events
app/Listeners
app/Jobs
app/Actions
app/Enums
app/Http/Requests
app/DataTransferObjects
app/DataFactories
app/Http/Controllers
app/Http/Models
app/Http/Resources
database/Migrations
database/seeders
resources/views
tests