Search by

nvl / media

nicolas_vls

Laravel media uploads, associations, variations and localized metadata

v7.5.1 2026-11-17 20:59 UTC

README

Media provides complete services for uploads, associations, private delivery, image variations, multipart uploads, scanning and storage recovery. Requires PHP 8.4 and Laravel 13.

composer require nvl/media:^7.0
php artisan vendor:publish --tag=nvl-media-config

Laravel discovers the provider automatically. The provider publishes its full runtime defaults to config/nvl-media.php; the configuration reference explains the settings. Configure the host before accepting uploads, then run php artisan nvl:media:doctor --production --strict.

To install the packaged agent guidance in the application's .agents/skills/nvl-media directory:

php artisan vendor:publish --tag=nvl-media-skills

Review local skill changes before republishing. The skill refers to the installed package's documentation under vendor/nvl/media/docs.

Consumers own their data objects, Actions, controllers, routes, resources and frontend types. Services accept explicit actors and native models, files, enums and documented arrays. Services retain validation, authorization, ownership admission, transactions, locks and after-commit cleanup.

use Nvl\Media\Services\MediaReader;

$assets = app(MediaReader::class)->paginate($actor, ['per_page' => 25, 'page' => 1]);

Bind the authorization contracts and register model slots with HasNvlMedia::registerNvlMedia() before writing media. SystemActor::Background requires an explicit policy grant. Optional Spatie Permission support does not bypass native ownership boundaries.

Configure Laravel filesystem disks, their allowlist and delivery policies, a scanner for untrusted files, and queue workers for image processing. Built-in S3 storage requires the optional SDK and adapter documented in S3; model-declared ownership requires the compatible nvl/ownership:^7.0 runtime. Unowned and local-only installations do not require either feature. Image drivers need their corresponding runtime extension/library. Services return native models and domain results; consumers shape public responses and protect private storage attributes.

Production server-proxied uploads require a real scanner by default. scanner.allow_unscanned_production explicitly allows operation with the no-op scanner and appears as a warning in Media Doctor. scanner.untrusted_uploads=false disables server-proxied untrusted ingestion. Multipart objects require scanner attestation before becoming available.

Publish nvl-media-config when configuration overrides are needed. Choose exactly one migration owner: automatic package migrations with nvl-media.migrations.enabled=true, or published nvl-media-migrations with automatic loading disabled. Review existing tables before applying migrations.

Pass a Nvl\Media\Slots\MediaPlacement as the collection argument to MediaAttachments::attach() when an asset's role and collection differ. Set the slot, locale, order and pivot metadata on the placement. The pivot records the role in metadata.slot. A slot size limit applies to its placements within the owner and collection.

For legacy px_media, px_media_associations, px_media_image_variations and px_media_translations, install the native schema in an empty standalone target. Freeze source and target writes during staging. Match each native disk's root and delivery settings to the legacy deployment so stored objects and public links remain usable. On PostgreSQL, index names are unique per schema, and GCT's px_media* tables use index names the native migrations also create (media_dedup_digest_disk_public, media_assoc_unique, media_var_label_idx). Before installing the native schema next to them, either rename the legacy indexes (for example ALTER INDEX media_assoc_unique RENAME TO px_media_assoc_unique; list them with select indexname from pg_indexes where tablename like 'px\_media%') or keep the legacy tables on a separate source connection or schema and pass its connection. Released migrations are not renamed. The source options accept connection, root_folder, conversions_folder, owner_types for morph mappings and uploader_type for legacy uploader IDs.

Run MediaSchemaAdopter::plan($actor, $source) with an actor authorized to manage staging. Resolve all conflicts and review the returned fingerprint. Pass it to apply($actor, $fingerprint, $source) to stage committed batches. After interruption, run the same call to resume. Run verify($actor, $fingerprint, $source) before switching application reads or writes. The adopter checks object presence and preserves IDs, timestamps and paths without copying files. Public variation links generated by Media include its normal cache version query parameter. New adoptions should run through php artisan nvl:adopt media plan|apply|verify|activate <manifest.json>, which checkpoints each batch and requires an explicit activate step after verification; see UPGRADING.

Both public and private URL defaults use application delivery. Public direct/CDN URLs are an explicit per-disk choice. Private URL reads return an authenticated endpoint; issuing signed application or provider temporary links requires an authorized actor and explicit expiration. See delivery configuration.

The package registers no HTTP routes. Consumers implement authenticated management and signed delivery endpoints using the package authorization and storage services. See HTTP integration.

The package ships its machine-readable consumer API catalog alongside these references. Use the documented native services and focused extension contracts when composing application adapters.