ankitpokhrel/tus-php
PHP server/client implementation of the tus resumable upload protocol. Supports large, chunked uploads with pause/resume, retries, and offsets; integrates with popular PHP frameworks and storage backends, offering configurable middleware, events, and validation.
Pros:
\Illuminate\Contracts\Filesystem\Filesystem).UploadStarted, UploadCompleted) enable seamless integration with Laravel’s job queues (e.g., process files post-upload via queues).Cons:
filesystem config (e.g., local, s3, ftp)./upload) or middleware.throttle middleware to prevent abuse.| Risk Area | Severity | Mitigation Strategy |
|---|---|---|
| Protocol compliance | Low | Test with tus clients (e.g., tus-js) early. |
| Storage corruption | Medium | Use Laravel’s filesystem drivers with checksum validation. |
| Concurrency issues | Medium | Implement upload locking (e.g., database locked_at field). |
| Laravel version skew | Low | Pin package version in composer.json. |
| Performance bottlenecks | Medium | Benchmark with large files; optimize chunk size. |
Storage Backend:
.tmp files) be managed during resumption?Authentication:
auth:api middleware suffice, or is a custom tus auth layer needed?Event Handling:
Scaling:
Monitoring:
Filesystem contracts (e.g., Storage::disk('s3')->put()) for seamless backend switching.UploadCompleted → dispatch FileUploaded event).FormRequest or Validate to sanitize upload metadata./api/upload for tus, /api/files for metadata).Phase 1: Proof of Concept (1–2 weeks)
composer require ankitpokhrel/tus-php.routes/web.php):
use AnkitPokhrel\Tus\TusController;
Route::tus('upload', TusController::class);
Phase 2: Laravel Integration (1–2 weeks)
Authorization header).
Route::tus('upload', TusController::class)->middleware('auth:api');
filesystem (if needed).UploadCompleted).
event(new FileUploaded($filePath, $metadata));
FormRequest.Phase 3: Production Readiness (1–2 weeks)
UploadFailed).throttle middleware to tus routes.local, s3, ftp, and custom drivers (implement Filesystem interface).php artisan serve) and production servers (e.g., Nginx, Apache).database (e.g., uploads table).composer.json (semver-compliant)..env.dd() or Log::debug() for tus events.config/tus.php).Upload-ID header), so multiple tus servers can share storage (e.g., S3).How can I help you explore Laravel packages today?