Download the PHP package edulazaro/laracrate without Composer

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

Laracrate

Polymorphic file storage for Laravel with direct upload to R2/S3, granular access control, sensitive content streaming, automatic image variants, video and PDF previews, per-variant watermarking, multipart uploads, text extraction, and vector embeddings.

Table of contents

  1. Philosophy
  2. Installation
  3. Data model
  4. Configuration
  5. Using it from your model
  6. Processing pipeline
  7. Variants
  8. Upload modes
  9. HTTP endpoints
  10. Sensitive content
  11. Artisan commands
  12. Optional Livewire component
  13. Full API
  14. Tests
  15. Dependencies
  16. License

Philosophy

  1. Backend agnostic to the frontend. The core has zero dependency on Livewire or Alpine. It exposes endpoints, a trait, and a service.
  2. Reuses Laravel's Storage::disk(). Disk credentials live in config/filesystems.php (single source of truth). The package does not duplicate configuration.
  3. Pipeline of Actions. Every operation is an isolated class (edulazaro/laractions), testable and queueable.
  4. Async processing. Variants, video and PDF previews, text extraction, embeddings, all run on the queue. The user upload is instant.
  5. 3 access modes per collection: public (direct CDN), signed (temporary signed URL), stream (controller with audit and viewer bind).
  6. path = full key convention. The path field on a File row stores the complete object key in the disk (directories, filename, extension). The name field is denormalization of basename($path).

Installation

migrate creates 3 tables, all with the laracrate_ prefix:

The laracrate_ prefix avoids clashing with legacy files tables that exist in many Laravel apps.

Disks in config/filesystems.php

Add the disks you intend to use (R2/S3 for real storage, local for dev):

Data model

Table laracrate_files

47 core columns plus JSON:

The three *_indexed_at columns let a single deployment migrate between ChunkStore backends (mysql → meilisearch → custom) without re-running the whole pipeline: a re-index job only re-syncs files where the target backend's timestamp is null or older than updated_at.

Visibility values come from the FileVisibility enum; processing states from ProcessingStatus.

Auxiliary tables

Each table has a matching Eloquent model under EduLazaro\Laracrate\Models\FileChunk, MultipartUpload, FileSlot, TenantBucket — that you can query directly when you need fine-grained access (e.g. listing chunks for debugging, aborting a specific multipart session by id, attaching slot rules to a workflow).

Key concepts

Configuration

Everything lives in config/laracrate.php (published with vendor:publish).

default_collection and default_context

Schema defaults applied when a File row is inserted without specifying them.

defaults, defaults per file type

These apply to every collection unless overridden. Each type defines accepted mime types, max size, quality, max dimensions, and default variants.

collections, definition of each collection

Each collection sets disk, access mode, accepted types with their config, and optionally single, sensitive, encrypt, ttl_hours, quota_bytes, component, placeholder.

Rules for types:

Granular per-model config (optional)

The same collection name can serve several models with different config per model, using an optional models block. The block is keyed by morph alias (or FQCN if you don't use a morph map). Each entry is merged on top of the base.

Semantics:

placeholders, fallback when there is no file

Resolution order (most specific to most general):

  1. config('laracrate.collections.{name}.placeholder')
  2. config('laracrate.placeholders.{type}')
  3. config('laracrate.placeholders.default')

Each slot accepts a fixed string or a dynamic closure:

urls, URL strategy

policies, bridge to Laravel's Gate

When register_gate is on you can use the native ergonomics:

Mapping: view/update/delete go to the registry's canView/canEdit/canDelete.

stream, streaming endpoints

status, polling endpoints

Endpoints:

multipart, large uploads

image, image processing

video, transcoding

Requires ffmpeg and ffprobe on the server's PATH.

encryption, encryption of sensitive binaries

If a collection sets 'encrypt' => true, the binary is encrypted with EncryptFileAction before being uploaded to the backend, and decrypted on the fly when served by StreamFileController.

embeddings, text extraction and vectors

Per-collection activation:

Custom provider:

Custom text extractor:

Bundled implementations:

Audio/video/image extractors call paid APIs — wire them in the extractors chain explicitly when you need them and check pricing for your workload.

chunks, persistence and search backend

Chunks produced by the embeddings pipeline (text split + vector) need a place to live. Laracrate ships two ChunkStore implementations and lets you wire a third one yourself.

Drivers:

Custom store (Qdrant, pgvector, Pinecone, etc.):

The ChunkStore contract has four methods: upsert, delete, search and countForFile. Pick whichever vector store fits your infra.

ocr, PDF scanning fallback

For PDFs that don't have extractable native text (scanned documents), the package ships OcrPdfTextExtractor. It sends the PDF base64 to an API and gets back the extracted text. No Imagick, no Ghostscript, no shell_exec, no pdftoppm. Just PHP and HTTP.

API key resolution, in order:

  1. Explicit constructor argument (advanced).
  2. Provider-specific LARACRATE_*_API_KEY (so the package has its own key, distinct from other usages in the app).
  3. Fallback to the generic provider env (ANTHROPIC_API_KEY, OPENAI_API_KEY).

Model resolution, in order:

  1. Provider-specific LARACRATE_OCR_{PROVIDER}_MODEL (e.g. LARACRATE_OCR_ANTHROPIC_MODEL).
  2. Generic LARACRATE_OCR_MODEL (applies to whichever provider is active).
  3. Hardcoded default (claude-haiku-4-5 / gpt-4o-mini).

Recommended chain for legal / scanned documents:

Cost reference per 10-page PDF (rough estimates, may change):

Provider Model Cost Native PDF
Anthropic claude-haiku-4-5 ~$0.004 yes (messages API document source)
OpenAI gpt-4o-mini ~$0.005 yes (Responses API input_file)

watermark, per-variant watermark

The watermark is baked into the binary of specific variants. The original (master) NEVER carries a watermark. Only variants that explicitly opt in.

Per-variant activation:

If you change the PNG or tweak sizes, regenerate the variants and the master stays untouched.

ui, default theme for the optional Livewire component

Only relevant if you use the optional Livewire component. Details in its section.

queue

Useful for isolating file processing from other queues.

Using it from your model

HasFiles trait

Server-side upload (regular request)

Direct upload to R2 (presigned, recommended)

JS client:

Backend confirm:

Multipart (large files, larger than 100 MB)

The JS helper detects the size and switches to multipart automatically when it crosses the threshold. The backend is already covered by the package routes.

Show in blade

$file->variant('preview.thumbnail') walks with dot notation and falls back to the closest real ancestor if the chain breaks (it never returns null). If you need to fail loudly, use variantOrFail().

Helpers fileLink() and fileRender()

They remove the null-check boilerplate:

fileLink() returns string|null. fileRender() returns HtmlString.

Default blade component per collection

Component in your app:

Delete, reorder, publish

Policies (authorization)

Defaults when no policy is registered:

Processing pipeline

When a top-level File is created (no parent_id), FileObserver::created dispatches ProcessFileJob (queue). The job orchestrates ProcessFileAction, which iterates the Steps of the ProcessingPipelineRegistry in ascending priority order.

Default steps shipped by the package:

Priority Step Triggers when
10 ExtractImageDimensions type === image
10 ExtractVideoDimensions type === video (requires ffprobe)
20 OptimizeImage type === image and collection.optimize_originals === true
25 TranscodeVideo type === video and collection.types.video.transcode === true
40 GenerateImageVariants type === image and there is a variants config
45 ExtractVideoPreview type === video and there is a preview config
45 ExtractPdfPreview type === document and mime === application/pdf
60 ExtractText extract_text or embed, and there is a TextExtractor for the mime
70 ChunkText embed === true and text was extracted
80 GenerateEmbedding embeddings.enabled, embed === true, and there are chunks

Priority convention:

Events:

Fail-fast policy: if a step throws, the File is left at processing_status = FAILED and ProcessFileJob retries with backoff (3 tries: 10s, 30s, 60s). Subsequent steps do not run on that attempt.

If the File is deleted before the worker reaches the job (typical when setFile() replaces an avatar), Laravel discards the job silently thanks to $deleteWhenMissingModels = true. No zombie entries in failed_jobs.

Extending the pipeline from your app

There are two extension points, depending on whether your step should run for every file in the system or only for a specific collection.

Global step (runs for every file)

Register at boot in the FileActionRegistry. The step's own supports() decides which files it actually touches.

Per-collection step (runs only for files in that collection)

Declare it under actions in the collection config — no service-provider wiring needed. Useful for domain-specific work (deadlines detection, document classification) that only makes sense for one collection.

Writing a step

Both registries expect classes implementing FileActionInterface (from edulazaro/laractions). supports() is optional; if absent, handle() runs for every file in scope.

The global registry and the collection's actions array are merged, deduplicated (by class), and sorted by priority() ascending before each pipeline run. Use the priority bands documented above (0-19 metadata, 20-39 transforms, 40-59 derivatives, 60-79 semantic, 80-99 AI) to slot your step where it makes sense.

Variants

Variants are child rows of laracrate_files with parent_id and variant. The cascade FK deletes them when you delete the parent. The FileObserver deletes the binary in R2 when the row is force-deleted.

Path convention

Helpers on the File model:

Per-variant watermark

The watermark is baked into the variant's binary at generation time. The original always stays clean. If you change the PNG or text tomorrow, regenerate the variants and you are done.

See the watermark config block.

Upload modes

Mode When to use Pros Cons
Via server (addFile($uploadedFile)) small files, strict server-side validation encrypt at rest possible, PHP validation binary flows through PHP
Direct presigned (PUT to R2) the normal flow no PHP in the upload path, scales well no encrypt at rest
Multipart (larger than 100 MB) large videos, datasets parallelizable parts, resumable more client complexity

The presign accepts fileable_type, fileable_id, and collection to generate the canonical key directly. If the model is unknown at upload time, the binary lands in temp/ and CreateFileAction moves it with S3 server-side copyObject (zero download to PHP).

HTTP endpoints

Method Route Description
POST /laracrate/uploads/presign Generate a presigned URL (single PUT)
DELETE /laracrate/uploads/{disk}/{encodedKey} Cancel a temp/ upload
POST /laracrate/multipart/init Start a multipart upload
POST /laracrate/multipart/{id}/parts Re-issue presigned URLs for parts
POST /laracrate/multipart/{id}/complete Assemble parts and register the File
DELETE /laracrate/multipart/{id} Abort a multipart session
GET /files/{slug}/stream Stream with audit (collections access=stream)
GET /files/{slug}/preview Stream without bumping last_downloaded_at
GET /files/{slug}/download Force download (Content-Disposition: attachment)
GET /laracrate/files/{slug}/status File status for polling after async upload
POST /laracrate/files/status Batch status of multiple slugs
POST /_laracrate/local/upload Local-driver upload (Laravel signed route)
GET /_laracrate/local/serve/{slug} Serve a File from the local disk

Sensitive content

For collections with access=stream, the per-request flow is:

  1. Package URL signed by Laravel (TTL route_signed_ttl).
  2. The controller validates the signature.
  3. If sensitive=true, validates Auth::id() === query('u') (URL bind).
  4. Policy chain, FilePolicy::view($file, $user) reads PolicyRegistry.
  5. If is_encrypted=true, DecryptFileAction decrypts before serving.
  6. Audit, increments last_downloaded_at, optionally logs IP and user_id.

The watermark is not applied here, it is baked into the variant.

Artisan commands

Recommended schedule in app/Console/Kernel.php:

Optional Livewire components

The package ships six Livewire components that cover the common upload UIs. All are fully optional: the core works without Livewire, and your app can build its own uploader or call addFile()/setFile() directly from your forms.

Component Use case
LaracrateUploader Card-style uploader for a single collection (avatar, cover, single doc).
LaracrateDropzone Multi-file dropzone with progress bars and previews.
LaracrateDropzoneSingle Single-file dropzone variant.
LaracrateUploaderDeferred Same as LaracrateUploader but renders only after the parent dispatches open.
LaracrateDropzoneDeferred Deferred-mount variant of LaracrateDropzone.
LaracrateDropzoneSingleDeferred Deferred-mount variant of LaracrateDropzoneSingle.

Deferred variants are useful inside modals or tabs where you don't want JS/CSS to load until the user opens the panel.

All components support 8 themes (default, brutalist, material, ios, glassmorphism, neon, minimal, neumorphism) and 2 layouts for the card uploader (row, portrait). The global theme is configured at config('laracrate.ui.default_theme').

Publish the views to customize:

If you do not use Livewire, ignore this section. Themes and the components are not loaded unless rendered.

Full API

HasFiles trait

File model

StorageManager service

UsageReporter service

Aggregates storage consumption across tenants, creators, or collections. Useful for billing, quotas, or dashboard widgets without writing custom SUM queries.

Each call returns a UsageStats value object:

forTenant honors the polymorphic tenant_* columns and includes variants of those files. forCollection is global across tenants.

Tests

Storage::fake() and SQLite in-memory, no Docker, no external services:

Tests cover the model, trait, observer, manager, policies, presigned controller, stream controller, multipart, and embeddings.

Dependencies

License

MIT


All versions of laracrate with dependencies

PHP Build Version
Package Version
Requires php Version >=8.2
laravel/framework Version >=12.0
edulazaro/laractions Version ^1.0
aws/aws-sdk-php Version ^3.300
intervention/image Version ^3.0
league/flysystem-aws-s3-v3 Version ^3.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 edulazaro/laracrate contains the following files

Loading the files please wait ...