ntzm / tusk
PSR-7 compatible tus server for PHP
Installs: 3
Dependents: 0
Suggesters: 0
Security: 0
Stars: 7
Watchers: 3
Forks: 1
Open Issues: 1
pkg:composer/ntzm/tusk
Requires
- php: ^7.2
- ext-json: *
- psr/event-dispatcher: ^1.0
- psr/http-message: ^1.0
- webmozart/assert: ^1.6
Requires (Dev)
- aws/aws-sdk-php: ^3.129
- friendsofphp/php-cs-fixer: ^2.16
- mikey179/vfsstream: ^1.6
- phpstan/phpstan: ^0.12.2
- phpstan/phpstan-phpunit: ^0.12.1
- phpstan/phpstan-webmozart-assert: ^0.12.0
- phpunit/phpunit: ^8.5
- slim/psr7: ^1.0
- slim/slim: ^4.3
- vimeo/psalm: ^3.7
- vlucas/phpdotenv: ^4.1
Suggests
- aws/aws-sdk-php: Required to use S3 storage
This package is auto-updated.
Last update: 2025-10-25 09:11:57 UTC
README
PSR-7 compatible tus server for PHP
Available storage drivers
S3
Stores files in S3
$storage = new Tusk\Storage\S3Storage(new Aws\S3\S3Client([ 'version' => '2006-03-01', 'region' => 'eu-west-1', ]), 'bucket-name');
See the documentation for PHP AWS SDK for more information.
ID Generation
By default, file IDs are created using the RandomHexIdGenerator, which should give you 32-character IDs that look like 69ed96b70ab30c8f046e79b74faf481b.
If you'd like to change how this works, you can inject a custom class that implements IdGenerator.
Location Generation
When a file upload begins, the server returns a URL that the client can continue to send data to.
By default this is whatever the POST URL is, plus the file ID.
This is handled by the RelativeLocationGenerator.
For example, if the POST endpoint's URL was /files, the file location would be files/<id>.
If you'd like to change this, you can inject a custom class that implements LocationGenerator.
Events
Tusk emits events when certain things happen during a file's lifecycle. You can hook into these with any PSR-14 compatible event dispatcher implementation.
UploadComplete
Tusk\Event\UploadComplete is fired when a file has been uploaded completely.
It has one method, fileId() which can be called to get the file's ID.
Compatibility
Tusk is compatible with tus 1.0.0 and the following extensions: