Download the PHP package micilini/video-stream without Composer
On this page you can find all versions of the php package micilini/video-stream. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package video-stream
Example of usage
Features
- Local streaming — stream local video files with proper HTTP Range support
- Remote streaming — proxy remote video URLs with native Range passthrough
- Disk cache — optional file-based cache for remote videos with TTL, LRU eviction, and stale fallback
- HTTP Range Requests — seek, scrub, and resume support for HTML5 players
- Events / hooks — listen to the streaming lifecycle in plain PHP or Laravel
- Temporary tokens — protect streams with signed, expiring tokens
- Rate limiting — limit concurrent streams and requests per minute by IP
- Subtitles — serve
.vtt/.srtsubtitles and associate subtitle tracks with videos - Laravel integration — Service Provider, Facade, publishable config, and Artisan commands
- Framework agnostic — works with Laravel, Symfony, Slim, CodeIgniter, or plain PHP
- Zero required third-party packages in the core — the main library relies on PHP 8.2+ and
ext-curl
Installation
Requirements
- PHP 8.2 or higher
- ext-curl
Quick Start
Plain PHP
Laravel
After installation, the Service Provider and Facade are auto-discovered.
Publish the config (optional):
Routes example:
Symfony
Other frameworks
API Overview
Main class
Fluent methods
| Method | Description |
|---|---|
->local(string $path) |
Set a local file as the video source |
->remote(string $url) |
Set a remote URL as the video source |
->contentType(string $type) |
Override the Content-Type header |
->buffer(int $bytes) |
Override the buffer size |
->cacheControl(string $value) |
Override the Cache-Control header |
->cache(...) |
Configure disk cache for remote videos |
->on(string $event, callable $listener) |
Register an event listener |
->withToken(...) |
Validate a signed token before streaming |
->rateLimit(...) |
Limit concurrent streams and requests by IP |
->subtitle(string $path) |
Output a subtitle file directly |
->subtitles(array $tracks) |
Associate subtitle tracks with a video |
->output() |
Stream directly via echo + flush |
->stream() |
Return StreamedResponse if Symfony is available, otherwise call output() |
VideoStream::generateToken(...) |
Generate a signed expiring token |
Disk Cache
For local videos, ->cache() is ignored.
Cache behavior
| Scenario | Behavior |
|---|---|
| Cache hit, not expired | Serve from disk immediately |
| Cache hit, expired, remote OK | Re-download and replace cache |
| Cache hit, expired, remote down | Serve stale cache |
| Cache miss, remote OK | Download, cache, and serve |
| Cache miss, remote down | Throw StreamException |
| Disk full | LRU eviction removes the oldest files |
Events / Hooks
Use events to monitor the stream lifecycle, add custom logging, or feed analytics.
Plain PHP
Available events
beforeStreamafterStreamonCacheHitonCacheMissonCacheExpiredonError
Laravel
In Laravel, you can bridge those hooks to framework events and listeners through the package integration layer.
Temporary Tokens
Use signed tokens to protect streaming URLs.
Generate a token
Validate before streaming
If the token is invalid or expired, the package throws an exception.
Rate Limiting
Limit the number of simultaneous streams and requests per minute for a given IP.
This is useful to reduce abuse and protect server resources without external infrastructure.
Subtitles
Output a subtitle file directly
Associate subtitles with a video
Supported subtitle scenarios:
.vttoutput.srtsupport.srtto.vttconversion when needed- subtitle metadata association through the video response pipeline
Example Demo
The repository includes a runnable example application under the example/ directory.
Suggested structure:
Notes
- Keep the demo HTML inside
example/ -
Use a relative base path in the frontend, such as:
- Open the demo through a local web server, not
file:// - The demo is useful to validate:
- local streaming
- remote streaming
- cache
- temporary tokens
- rate limiting
- subtitles
- event logging
Laravel Configuration
After publishing the config:
A typical config/video-stream.php may include:
Example .env
Artisan commands
Project Structure
Testing
The test suite should cover:
StreamConfigvalidation- HTTP Range parsing
- local streaming
- remote streaming
- cache TTL / eviction / stale fallback
- event dispatching
- token generation and validation
- rate limiting
- subtitle output and conversion
- integration with the fluent API
Upgrade Notes
If you removed the legacy v1-style API in the new major version, document that change in an UPGRADE.md file and keep the README focused on the fluent API only.
Contributing
Pull requests are welcome. For major changes, open an issue first so the scope can be discussed before implementation.
License
MIT
All versions of video-stream with dependencies
ext-curl Version *