Upgrading from 1.x
Each item says what changed and what to do. Run the new migrations first:
php artisan migrate
0000_00_00_000041 rewrites access to public or private, and 0000_00_00_000042 adds the mode column. Until 041 runs, rows read fine, but new rows fail to insert, because the access column does not accept private yet.
Access and URLs
-
accessispublicorprivate.signedandstreamare gone as values. The migration rewrites them toprivate, and marks thestreamrowssensitiveso they keep being served only through PHP. In your config, write'access' => 'private'(add'sensitive' => truewhere you hadstream). The 1.x values are still read,streamas private plus sensitive, so nothing breaks while you change them. -
How a private file is served is chosen per use, not per collection.
$file->url()is the direct link. Private: a link signed straight to the disk, which expires afterlaracrate.urls.signed_ttl, or when you say withurl(expires: now()->addHours(3))(S3/R2 refuse more than 7 days). Encrypted or sensitive: the stream route.$file->streamUrl()and$file->downloadUrl()serve the file through PHP. They carry no signature and never expire: the routes sit behind the session and checkcanViewon every request. Keepauthinlaracrate.stream.middleware.
-
previewUrl()and thelaracrate.files.previewroute are removed. UsestreamUrl(): it shows the file inline and, likepreviewdid, does not count a download. Onlydownloadcounts now. -
The viewer endpoint is
/viewer, namedlaracrate.files.viewer(it wasview). Update anyroute('laracrate.files.view', …). -
Removed:
- the config keys
urls.route_signed_ttl,urls.bind_to_userandurls.sensitive_redirect_ttl; - the
uquery parameter; GenerateSensitiveStreamUrlAction;StreamFileController::link().
Delete the keys from your published config.
- the config keys
Variants, previews and video
-
Video and PDF variants are declared in
variants, with atype, under the names your app chooses:video: an MP4 copy, or a teaser withclips/seconds/audio/generator;image: a frame (frame_at) or a PDF page (page, 1-indexed);frames: a strip of frames.
Nested
variantsare made from their variant. See "Video and PDF variants" in the README. -
previewnames a variant now. A type's'preview' => [...]block (frame_at,page,variants) is refused with anInvalidArgumentExceptionthat says what to write. Move it intovariantsand pointpreviewat it. To keep the rows already generated underpreview, keep that name:// 1.x 'video' => ['preview' => ['frame_at' => '00:00:01', 'variants' => ['thumbnail' => ['width' => 300]]]], // 2.0 'video' => [ 'variants' => ['preview' => ['type' => 'image', 'frame_at' => '00:00:01', 'variants' => ['thumbnail' => ['width' => 300]]]], 'preview' => 'preview.thumbnail', ],
For a PDF, the same with
'type' => 'image', 'page' => 1. -
$file->preview()returns the variant the type'spreviewnames, ornull.preview_linkreads it instead of looking uppreview.thumbnail. Without apreviewin the config, a video or a PDF gets the placeholder and an image gets itself. -
File::playback()and'transcode' => 'variant'are removed.- Declare the copy in
variantsand read it by name:'variants' => ['playback']keeps the rows already calledplayback, and$file->variant('playback')reads it. 'transcode' => 'variant'is refused with a message.'transcode' => truestill replaces the original.TranscodeVideoActionno longer takeskeepOriginal.
- Declare the copy in
-
The viewer plays the video variant in
laracrate.viewer.video_variant(none by default), as it shows the image one inimage_variant. Set it to your copy's name, for example'playback', to keep the 1.x behaviour. -
Removed classes:
ExtractVideoPreviewAction,ExtractVideoPreviewStepandExtractPdfPreviewStep.ExtractPdfPreviewActionis nowRenderPdfPageAction, which takes the variantname. If you registered or extended them, useGenerateVideoVariantsAction/GenerateVideoVariantsStep,GeneratePdfVariantsStepandRenderPdfPageAction.
Types
- Images have a
mode:default,sphere(a 360° photo) orframes(a strip of a video's frames). Theirtypestaysimage, so existing checks and queries ontypekeep working. - 360° photos are told apart only where the collection's image type takes that mode (
'image' => ['modes' => ['default', 'sphere']]); otherwise they staydefault. They are recognised by their XMP (GPano:ProjectionType="equirectangular"), not by their proportions. An app that marked them withcategorycan move tomode = 'sphere'.
Livewire components and themes
- Three components, with
deferredas a prop. The tagslaracrate-uploader-deferred,laracrate-dropzone-deferredandlaracrate-dropzone-single-deferredare removed. Write<livewire:laracrate-uploader :deferred="true" />, and likewise for the two dropzones. - The look is one CSS file. Import
vendor/edulazaro/laracrate/resources/css/laracrate.cssonce in your app's CSS. There is one view per component and no view per theme:- the views are no longer published (the
laracrate-viewstag is gone); - delete any copies in
resources/views/vendor/laracrate, since they would override the new views.
- the views are no longer published (the
- Themes:
- pick one per page with
data-wire-themeon an ancestor, or per component withtheme="…"; - customise with the
rounded,bordered,shadow,size,classandstyleprops, and the--wire-laracrate-*variables; ui.default_themeandLARACRATE_THEMEare removed.
- pick one per page with
- CSS classes use
laracrate-. Thelc-classes of the tray, the viewer and the handoff page are nowlaracrate-…. Update any CSS that targets them.
Uploads
- The components upload in
presignmode by default (laracrate.uploads.mode, optionallyLARACRATE_UPLOAD_MODE, orupload-modeper component). The component signs the picked files itself and the browser never names a target.grantmode keeps the 1.x flow. - An
UploadGrantbelongs to the user and the browser session it was issued in, and can cap its files withmaxFiles:- issue it from the user's request, for example a Livewire method;
- a token used from another session, or by another user, is refused;
UploadGrant::for(..., maxFiles: $count)limits how many files it signs.
- Presign only signs into
temp/. The plainpresignendpoint ignores model parameters. Register the object withaddFile(FileUpload::fromArray([...])), which moves it to its final key.cancelonly deletes atemp/key this browser signed. - Multipart runs under a grant.
inittakes the grant, andparts,completeandabortonly answer to the grant that started the session.- The routes take
laracrate.multipart.middleware, orlaracrate.uploads.middlewarewhen it is null. In 1.x a null multipart middleware left them open: still on 1.x, set'middleware' => ['web', 'auth']there.
addFile()measures the size. With aFileUpload, the object's real size is read from the bucket and checked against the collection. The declaredsizeis ignored, and an object that is too big or missing is refused (UploadRejected, reasonsizeormissing) and deleted.- Removed:
registerUploaded()from the components (presign mode registers throughlaracrate/uploads/register);setSlots()from the dropzone;folder()fromUploaderHasFolderTarget(the components keep a lockedfolderId).
built and maintained by Edu Lazaro · MIT license