Download the PHP package rajurayhan/larastreamer without Composer

On this page you can find all versions of the php package rajurayhan/larastreamer. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package larastreamer

Larastreamer

A lightweight, storage-agnostic video streaming engine for Laravel — HTTP Range, signed URLs, authorization, and cloud disks.

Not a transcoding platform. It does not generate renditions, package HLS/DASH, or talk to Mux / Cloudflare Stream. Delivery only.

Requires PHP 8.3+ and Laravel 12 or 13.

Status: 3.0. Progressive MP4 by default. Opt-in HLS/DASH serving, captions, metadata, and a Streamable model trait. The v1 Raju\Streamer\Helpers\VideoStream class was removed — use Streamer::file($path)->stream().

See docs/v3.md for the 3.0 design notes.


Contents


Installation

The service provider and Streamer facade alias register automatically.

Publish the configuration (optional — values are merged even if you skip this):

Publish the player views (optional):

Add a disk in config/filesystems.php if you keep videos off the default local disk:

Point Larastreamer at that disk (or leave the defaults and prefix files under uploads/):


Quick start


Usage

Fluent API

Every delivery call starts from the Streamer facade and a PendingStream builder.

Method Returns Purpose
Streamer::file($path) PendingStream Default disk, prefixed with storage.path (uploads by default)
Streamer::disk($name) PendingStream Named Laravel disk; later file() paths are used as-is
->file($path) PendingStream Relative disk path, or an absolute local file that exists
->captions($tracks) PendingStream VTT/SRT tracks for stream() / embedData() / the player
->authorize($cb) PendingStream Per-call authorization (this request only)
->drm($configuration) PendingStream Attach a DrmConfiguration or application DrmProvider
->stream() Response Stream, redirect, offload, or rewrite a playlist
->download() Response Attachment disposition (remote disks 302)
->redirect($expires) Response 302 to a disk temporaryUrl()
->temporaryUrl($expires) string Cloud signed URL
->meta() VideoMeta Size, MIME, mtime, ETag; duration/codec if a Probe is bound
->embedData($expires) array Public URL payload for a player
Streamer::signedUrl($path, $expires) string App-signed built-in route URL
Streamer::authorize($cb) Streamer Request-scoped default authorizer

$expires on redirect(), temporaryUrl(), embedData(), and signedUrl() accepts a DateTimeInterface, an integer number of seconds, or null (uses security.default_expiration, 1800 seconds).

Controllers and routes

Use your own routes. The package route is off by default.

Default disk vs named disk

Streamer::file($path) uses storage.disk and prefixes storage.path (uploads by default), unless $path is already under that prefix or is an existing absolute local file.

Streamer::disk('videos')->file($path) uses that path on the given disk as-is. No uploads/ prefix.

Streamable models

No migrations. The model already has a path column (and optionally disk / captions).

streamUrl() and embedData() need a resolvable public URL (signed route for local disks, temporaryUrl() for remote). They never return a raw disk path.

Cloud disks

Any Laravel filesystem disk works. Local disks are streamed (or offloaded). S3, R2, Spaces, MinIO, and Wasabi go through Flysystem — no custom SDKs.

Remote objects redirect by default (storage.remote.strategy = redirect), including download(). Do not proxy gigabytes through PHP unless you set the strategy to proxy.

To proxy a private bucket through PHP (small files, or when every byte must run authorize/events):

Signed URLs

Built-in routes are off by default. When you enable them, Laravel's signed middleware is required. security.signed_urls is enforced: if it is false, signedUrl() throws and the built-in route 404s.

The route is GET /stream?file=courses/lesson-01.mp4 (not /{filename}). Nested paths work because the file is a query parameter.

Unsigned, expired, and tampered signatures are rejected by Laravel (403). Missing file or security.signed_urls = false is 404.

embedData() returns a signed URL when routes are on. If routes are off, pass url: to the player or catch StreamException.

Authorization

Default: allow (the app already decided to call stream(), or the signed route already validated the signature).

Bind a process-wide policy in a service provider:

Streamer::authorize() is request-scoped and does not leak to the next HTTP request:

Denied requests return 403 and dispatch VideoStreamUnauthorized. The per-call hook wins over the request-scoped hook, which wins over the container binding.

Metadata

Duration and codec are filled only when you bind an optional Probe. There is no FFprobe dependency.

Captions

.vtt and .srt are served through the same jail and signed route. The player renders <track kind="subtitles">.

embedData()['captions'] rewrites each src to a public URL (signed or temporary). Tracks that fail to resolve are omitted.

Disable caption serving with captions.enabled = false.

HLS and DASH serving (opt-in)

Progressive MP4 is the default. HLS/DASH serving is off until you enable it. Transcoding is not in 3.0 — no FFmpeg.

When enabled, those extensions and MIME types are merged into the allowlist. When disabled, .m3u8 / .mpd are 404.

Kind Extensions MIME
HLS playlist m3u8 application/vnd.apple.mpegurl (and common aliases)
HLS segments ts, m4s video/mp2t, video/iso.segment
DASH mpd, m4s application/dash+xml

stream() on a .m3u8 / .mpd rewrites relative segment (and #EXT-X-KEY / #EXT-X-MAP / #EXT-X-MEDIA) URIs:

Absolute https:// URIs are left alone. ../ inside a playlist is 404. Playlists are Cache-Control: private, max-age=0, no-store. Segments are not fetched during rewrite.

Safari can play HLS natively. For Chrome/Firefox set hls.player to hlsjs and use the Blade player — HLS.js is loaded from hls.hlsjs_src, not vendored in Composer.

DRM playback

Larastreamer can play externally packaged encrypted HLS or DASH through the existing Blade component. It does not encrypt media, store content keys, issue licenses, or proxy license challenges. Widevine, PlayReady, and FairPlay therefore require a compatible external packager and licensed DRM service. ClearKey is suitable only for development.

The Blade component accepts the same configuration and keeps its existing public API:

You can implement Raju\Streamer\Contracts\DrmProvider when license URLs or short-lived headers depend on the viewer or asset. Its configuration(DrmContext $context) method runs only after Larastreamer authorizes and resolves the requested manifest. The browser receives only the allowlisted license/content/certificate headers and Shaka robustness settings in DrmConfiguration; never pass raw content keys, private keys, vendor server credentials, or long-lived client secrets.

All DRM endpoint URLs require HTTPS, except loopback HTTP URLs for local development. The default player engine is the pinned https://cdn.jsdelivr.net/npm/[email protected]/dist/shaka-player.compiled.js build; set drm.shaka_src to a self-hosted copy if required. Shaka is loaded only when DRM data is attached, so ordinary progressive and HLS playback remains unchanged.

For production, prefer encrypted assets in a private S3-compatible origin behind a CDN and provide manifestUrl. The CDN then serves manifest and segment bytes without placing PHP in the hot path. If an encrypted manifest is on a local disk and has no override, Larastreamer creates an encrypted, expiring bearer ticket scoped to that disk, asset directory, and current user. The initial authorize() callback decides whether that capability may be issued; callbacks are not serialized or replayed on later browser requests. Every playback request still validates the ticket and user identity, applies the filesystem jail and MIME checks, and runs the application's bound Authorization implementation. The default web middleware hydrates Laravel's session; add auth to drm.playback_middleware if the viewer must remain logged in throughout playback.

The player emits safe lifecycle events without URLs, headers, license payloads, or provider error messages:

DRM protects decryption keys and raises the cost of copying media; it cannot prevent screen capture.

Downloads

Local files send Content-Disposition: attachment. Remote disks 302 to a temporary URL with ResponseContentDisposition — they do not stream the object through PHP.

Player

Prop Type Notes
src string Disk-relative path. Resolved through embedData() (signed/temporary URL).
url string Public URL. Skips disk resolution. Use this when routes are off.
mime string type on <source>
poster string Native poster
autoplay bool Default false
controls bool Default true
captions array Override tracks; otherwise uses embedData()['captions']
disk string Named disk used when resolving src
drm DrmConfiguration\|DrmProvider Enables conditional protected playback through Shaka

Extra HTML attributes pass through to <video>.

Native <video> by default. No JavaScript is vendored. If hls.player = hlsjs and the source is a playlist, the component loads HLS.js from hls.hlsjs_src.

If there is no resolvable public URL, the tag is an empty <video data-empty="true"> with no <source> — never a disk path.

Events

Listen in your app as usual:

Event When
VideoStreamStarted Delivery begins
VideoStreamCompleted After the body is sent (local BinaryFileResponse uses a terminating callback)
VideoStreamFailed Missing file, bad MIME, or other stream error
VideoStreamUnauthorized authorize() returned false

Payloads are small: path, disk, user id, range, strategy (file / offload / proxy / redirect / playlist). VideoStreamFailed also has a reason.

Exceptions

Responses never include absolute server paths.

Exception Status When
VideoNotFound 404 Missing, empty, directory, traversal, or disallowed MIME/extension
UnauthorizedStream 403 Authorizer returned false
InvalidRange 416 Unsatisfiable Range (Content-Range: bytes */{size})
StreamException 500 Signed routes disabled, embed URL cannot be built, and other delivery errors

signedUrl() and embedData() throw StreamException when a public URL cannot be built. stream() / download() / redirect() convert package exceptions into HTTP responses.


HTTP Range, HEAD, and validators

Request Status Headers
Full GET 200 Content-Type, Content-Length, Accept-Ranges: bytes, ETag, Last-Modified
Valid Range 206 Content-Length of the range, Content-Range: bytes {start}-{end}/{size}
If-None-Match matches, no Range 304 Empty body, ETag / Last-Modified
If-Range mismatch 200 Full body, Range ignored
Invalid Range 416 Content-Range: bytes */{size}
HEAD same headers as GET no body

Supported ranges: bytes=0-999, bytes=1000-, bytes=-500.

ETag is weak: W/"{size}-{mtime}" locally, or a path hash when mtime is missing on a remote object.


Offload (local only)

Larastreamer returns an empty body plus X-Accel-Redirect or X-Sendfile. nginx honors the original request Range and serves 206; PHP does not consume the file. Apache X-Sendfile does not reliably forward Range — disable offload or use nginx if clients need byte ranges.

Example nginx location:

The alias must match the disk root (plus storage.path if you use the default prefix). Tests assert headers only; nginx must be configured in the environment.


Security


Configuration

See config/larastreamer.php after publishing.

Key Default Notes
route.enabled false Load GET /{prefix}?file=
route.prefix stream URL prefix
route.middleware ['signed'] Required when the route is on
route.name larastreamer.stream Used by signedUrl()
storage.disk env('LARASTREAMER_DISK', 'local') Default disk for Streamer::file()
storage.path env('LARASTREAMER_PATH', 'uploads') Prefix for Streamer::file() only
storage.remote.strategy redirect redirect or proxy
streaming.buffer_size 1048576 Proxy read chunk size
streaming.max_age 3600 Cache-Control max-age
streaming.cache private private or public
security.signed_urls true Enforced for the built-in route
security.default_expiration 1800 Seconds when $expires is omitted
allowed_mimes progressive video types Extra HLS/DASH/caption types merge when enabled
allowed_extensions mp4, webm, ogv, mov, avi, mpeg, mpg Same merge rules
hls.enabled / dash.enabled false Opt-in playlist serving
hls.rewrite / dash.rewrite true Rewrite relative URIs
hls.player native native or hlsjs
hls.hlsjs_src jsDelivr HLS.js CDN string only
drm.enabled true Enable DRM configuration and the local playback route
drm.shaka_src pinned Shaka Player 5.2.9 May be replaced with a self-hosted build
drm.playback_route_name larastreamer.playback Local encrypted asset route name
drm.playback_middleware ['web'] Middleware for local DRM asset requests; add auth when required
captions.enabled true Allow .vtt / .srt
offload.enabled false Local sendfile / accel

Migrating from v2 / v1

Old 3.0
Raju\Streamer\Helpers\VideoStream Removed. Streamer::file($path)->stream()
Streamer::authorize() mutates a singleton Request-scoped StreamContext
embedData()['url'] as a disk path Signed URL, or StreamException
Unused security.signed_urls Enforced
HLS types in a custom allowlist Enable hls.enabled / dash.enabled

Production notes


Testing


License

MIT


All versions of larastreamer with dependencies

PHP Build Version
Package Version
Requires php Version ^8.3
illuminate/contracts Version ^12.0 || ^13.0
illuminate/filesystem Version ^12.0 || ^13.0
illuminate/http Version ^12.0 || ^13.0
illuminate/routing Version ^12.0 || ^13.0
illuminate/support Version ^12.0 || ^13.0
illuminate/view Version ^12.0 || ^13.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package rajurayhan/larastreamer contains the following files

Loading the files please wait ...