Download the PHP package netipar/laravel-chunky without Composer

On this page you can find all versions of the php package netipar/laravel-chunky. 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 laravel-chunky

Chunky for Laravel

Latest Version on Packagist Tests Total Downloads

Chunk-based file upload package for Laravel with event-driven architecture, resume support, and framework-agnostic frontend clients for Vue 3, React, Alpine.js, and Livewire. Upload large files reliably over unstable connections.

Table of contents

Additional documentation:

Quick Example

Requirements

5-Minute Quickstart

Production Deployment Checklist

Installation

Backend

Publish the config file:

Run the migrations (for database tracker):

Frontend

Install the package for your framework:

The @netipar/chunky-core package is automatically installed as a dependency of all framework packages.

Livewire

No npm package needed. The Livewire component uses Alpine.js under the hood and is included in the Composer package. Just add the component to your Blade template:

Frontend Packages

Package Framework Peer Dependencies
@netipar/chunky-core None (vanilla JS/TS) -
@netipar/chunky-vue3 Vue 3.4+ vue
@netipar/chunky-react React 18+ / 19+ react
@netipar/chunky-alpine Alpine.js 3+ -

Usage

How It Works

  1. Frontend initiates an upload with file metadata
  2. Backend returns an upload_id, chunk_size, and total_chunks
  3. Frontend slices the file and uploads chunks in parallel with SHA-256 checksums
  4. Backend stores each chunk, verifies integrity, tracks progress
  5. When all chunks arrive, an AssembleFileJob merges them on the queue
  6. Events fire at each step -- hook in your own listeners

CSRF Protection

The frontend client automatically reads the XSRF-TOKEN cookie (set by Laravel) and sends it as the X-XSRF-TOKEN header. No manual CSRF setup is needed in most Laravel applications.

If you need a custom token header, use setDefaults():

Config Isolation

For multiple upload scopes on the same page:

API Endpoints

The package registers seven routes (configurable prefix/middleware):

Method Endpoint Purpose
POST /api/chunky/upload Initiate upload
POST /api/chunky/upload/{uploadId}/chunks Upload a chunk
GET /api/chunky/upload/{uploadId} Get upload status
DELETE /api/chunky/upload/{uploadId} Cancel upload
POST /api/chunky/batch Initiate batch
POST /api/chunky/batch/{batchId}/upload Add file to batch
GET /api/chunky/batch/{batchId} Get batch status

HTTP status codes

Code When
201 Created Upload or batch initiated
200 OK Chunk accepted, status fetched
204 No Content Cancel succeeded
404 Not Found Upload/batch doesn't exist — or the caller isn't its owner (intentional, prevents probe attacks)
409 Conflict Late chunk against a cancelled / completed / failed / assembling upload
410 Gone Upload has expired
422 Unprocessable Entity Validation error (missing field, invalid file_name, batch in terminal state, etc.)
503 Service Unavailable Upload temporarily contended on the lock; client may safely retry (idempotent)

Vue 3

React

Alpine.js

Livewire

Listen for the upload completion in your Livewire parent component:

Core (Framework-agnostic)

Batch Upload (Multiple Files)

Upload multiple files as a batch and get a single event when all files are done.

Vue 3

React

Alpine.js

Core (Framework-agnostic)

How Batch Works

  1. Frontend calls POST /api/chunky/batch with total_files count
  2. Backend creates a batch record and returns batch_id
  3. For each file, frontend calls POST /api/chunky/batch/{batchId}/upload to initiate
  4. Chunks are uploaded normally via POST /api/chunky/upload/{uploadId}/chunks
  5. When each file's assembly completes, the batch counter increments atomically
  6. When all files are done, BatchCompleted (or BatchPartiallyCompleted) event fires

Every upload creates a batch — even a single file becomes a batch of 1. This ensures consistent behavior: every upload gets a batchId and fires BatchCompleted. useBatchUpload is the single entry point for all uploads.

Failure policy: Lenient -- if a file fails, other files continue. The batch ends with PartiallyCompleted status.

Sequential Batches with enqueue()

upload() throws if a batch is already in progress on the same BatchUploader instance. For UIs that accept files faster than they can upload (multi-paste, drag-while-uploading), use enqueue() instead:

If you cancel() or destroy() the uploader before a queued batch starts, its promise rejects with a clear error message. The Vue 3 / React / Alpine wrappers all expose enqueue as a sibling of upload.

Authentication & Authorization

Authentication

By default, upload endpoints use only the api middleware. To protect them with authentication, update routes.middleware in config/chunky.php:

This applies to all routes (initiate, upload chunk, cancel, status, batch). No custom request or controller override is needed.

Authorization (per-upload, per-batch)

When auth is active, the package automatically enforces ownership: an authenticated caller can only access uploads / batches they created (the user_id captured at initiation time). Non-owners see a 404 (not 403) so upload IDs can't be probed.

The check is delegated to a swappable Authorizer interface:

The default DefaultAuthorizer does plain ownership: auth()->id() === upload->userId, with anonymous uploads (no user_id) accessible to everyone (backward compat).

Custom Authorizer (admin overrides, team access, …)

Bind your own implementation in AppServiceProvider::register():

The same Authorizer is used by the broadcast channel auth callbacks (routes/channels.php, auto-registered when broadcasting.enabled = true) — HTTP and WebSocket access stay in sync.

user_id is portable

The chunked_uploads.user_id and chunky_batches.user_id columns are string type since v0.14, so any user-id shape works out of the box: auto-increment integers, UUIDs, ULIDs, or arbitrary strings. The package never does arithmetic on user_id, only string equality comparisons.

Quick Context Setup

For the most common case -- validate and move the file to a directory:

This registers a context that validates the file and moves it from the temp directory to uploads/documents/{fileName} after assembly. No event listener needed.

Context-based Validation & Save Callbacks

Contexts define per-upload validation rules and save handlers. You can use class-based contexts (recommended) or inline closures.

Class-based Contexts (Recommended)

Create a context class:

Register via config (config/chunky.php):

Or register manually in your AppServiceProvider:

Inline Closures

For simple cases, you can register contexts inline:

Using Contexts from Frontend

Listening to Events

Register listeners in your EventServiceProvider:

Example listener:

Available Events

Event Payload When Broadcasts?
UploadInitiated uploadId, fileName, fileSize, totalChunks Upload initialized
ChunkUploaded uploadId, chunkIndex, totalChunks, progress% After each successful chunk
ChunkUploadFailed uploadId, chunkIndex, exception On chunk error
FileAssembled uploadId, finalPath, disk, fileName, fileSize After file assembly
UploadCompleted upload (UploadMetadata) Full upload complete
UploadFailed upload (UploadMetadata), reason Save callback failed or assembly job exhausted retries
BatchInitiated batchId, totalFiles Batch created
BatchCompleted batchId, totalFiles All batch files completed
BatchPartiallyCompleted batchId, completedFiles, failedFiles, totalFiles Batch done with failures

Broadcasting (Laravel Echo)

Get real-time notifications when uploads or batches complete. Broadcasting is disabled by default -- enable it in your .env:

Four events are broadcastable: UploadCompleted, UploadFailed, BatchCompleted, and BatchPartiallyCompleted. They use private channels — when chunky.broadcasting.register_channels = true (default), the package auto-registers Broadcast::channel() callbacks that delegate to the bound Authorizer, so the same ownership rules apply on HTTP and WebSocket.

If you set register_channels = false, register them manually in your routes/channels.php:

Vue 3

React

Batch Echo

Core (Framework-agnostic)

User Channel

Instead of subscribing per-upload or per-batch, listen on the user channel to receive all upload events — even after page reload:

The user channel requires authenticated routes (auth:sanctum middleware) and user_id is automatically captured from auth()->id() during upload initiation.

Using the Facade

Configuration

The full configuration reference lives in docs/configuration.md — every key, default, and the common deployment recipes (large videos, S3, authenticated routes, per-chunk progress broadcast). The TL;DR .env:

Publish the config to customise:

The config is grouped into 10 sections (since v0.18): storage, chunks, lifecycle, limits, metadata, locking, idempotency, cache, authorization, broadcasting. Older flat keys were renamed — see UPGRADE.md for the full migration table.

Tracking Drivers

Database (default)

Uses the chunked_uploads table. Best for production -- queryable, reliable, supports status tracking.

Filesystem

Uses JSON metadata files on disk. Zero database dependency -- useful for simple setups.

Error Handling

Examples

Testing

Credits

License

The MIT License (MIT). Please see License File for more information.


All versions of laravel-chunky with dependencies

PHP Build Version
Package Version
Requires php Version ^8.2
illuminate/support Version ^11.0|^12.0|^13.0
illuminate/http Version ^11.0|^12.0|^13.0
illuminate/routing Version ^11.0|^12.0|^13.0
illuminate/database Version ^11.0|^12.0|^13.0
illuminate/filesystem Version ^11.0|^12.0|^13.0
illuminate/bus Version ^11.0|^12.0|^13.0
illuminate/queue Version ^11.0|^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 netipar/laravel-chunky contains the following files

Loading the files please wait ...