Skip to content

Latest commit

 

History

History
146 lines (101 loc) · 3.13 KB

File metadata and controls

146 lines (101 loc) · 3.13 KB
title Installation
order 2

Installation

Install Package

composer require axn/livewire-upload-handler

Add Blade Directives

In your layout file (e.g., resources/views/layouts/app.blade.php):

<head>
    @livewireStyles
    @livewireUploadHandlerStyles
</head>
<body>
    <!-- Your content -->

    @livewireScripts
    @livewireUploadHandlerScripts
</body>

Publish Assets (Optional)

Config

php artisan vendor:publish --tag=livewire-upload-handler:config

Creates config/livewire-upload-handler.php

Translations

php artisan vendor:publish --tag=livewire-upload-handler:translations

Publishes to lang/vendor/livewire-upload-handler/

Views

php artisan vendor:publish --tag=livewire-upload-handler:views

Publishes to resources/views/vendor/livewire-upload-handler/

Themes

php artisan vendor:publish --tag=livewire-upload-handler:themes

Publishes themes to resources/vendor/livewire-upload-handler/themes/

Environment Variables

Add to .env for Glide configuration:

GLIDE_IMAGE_DRIVER=gd  # or 'imagick'
GLIDE_SIGN_KEY=your-random-secret-key

Generate a sign key:

php -r "echo bin2hex(random_bytes(32));"

Git Configuration (Important)

When using Livewire uploads, two temporary file directories are automatically created:

  1. storage/app/livewire-tmp/ - Livewire temporary files (created by Livewire)
  2. storage/app/.livewire-upload-handler-glide-cache/ - Glide preview cache (created by this package)

These directories should not be versioned in Git as they contain automatically regenerated temporary files.

Required Configuration

Add livewire-tmp/ to your application's main .gitignore:

storage/app/.gitignore

*
!public/
!.gitignore
livewire-tmp/

Also create a dedicated .gitignore for the Glide cache:

storage/app/.livewire-upload-handler-glide-cache/.gitignore

*
!.gitignore

Why?

livewire-tmp/: Temporarily stores uploaded files during processing. These files are automatically cleaned by Livewire.

.livewire-upload-handler-glide-cache/: Stores image previews generated by Glide during uploads. These files are:

  • Temporary and regenerated on demand
  • Environment-specific
  • Unnecessary in the Git repository (increase repository size without reason)

Automatic File Creation

You can create these configurations manually or use this command:

# Add livewire-tmp/ to main .gitignore
if ! grep -q "livewire-tmp/" storage/app/.gitignore 2>/dev/null; then
    echo "livewire-tmp/" >> storage/app/.gitignore
fi

# Create .gitignore for Glide cache
mkdir -p storage/app/.livewire-upload-handler-glide-cache && \
echo "*" > storage/app/.livewire-upload-handler-glide-cache/.gitignore && \
echo "!.gitignore" >> storage/app/.livewire-upload-handler-glide-cache/.gitignore

Next Steps