Download the PHP package christopheraseidl/laravel-auto-filer without Composer
On this page you can find all versions of the php package christopheraseidl/laravel-auto-filer. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download christopheraseidl/laravel-auto-filer
More information about christopheraseidl/laravel-auto-filer
Files in christopheraseidl/laravel-auto-filer
Package laravel-auto-filer
Short Description A simple package for automating the organization of files associated with models.
License MIT
Homepage https://github.com/christopheraseidl/laravel-auto-filer
Informations about the package laravel-auto-filer
Automated file organization for Eloquent Models
Laravel Auto Filer is a simple package that automates file organization for your Eloquent models. It handles file uploads, moves them to organized directories, and automatically cleans up files when they are deleted from the model or when their models are deleted.
Key features
- Automatic file organization: files are organized in a predictable structure:
model_type/model_id/subfolder/filename
. - Automatic file movement: files are automatically moved from temporary to permanent locations when models are saved.
- Automatic cleanup: files are deleted when their associated models are deleted or when the files have been removed from the model.
- Rich text field support: automatically handles files embedded in rich text content.
- Thumbnail generation: automatic thumbnail creation for images with automatic cleanup.
- Circuit breaker protection: built-in circuit breaker prevents cascading failures.
- Laravel 10, 11, and 12 support: compatible with recent Laravel versions.
Installation
You can install the package via composer:
You can optionally publish the config file:
Usage
Add the HasAutoFiles
trait to your model and define which attributes should handle file uploads:
How it works
- File upload: Upload files to a temporary location and store the paths in your model attributes.
- Model save: When the model is saved, files are automatically moved to their permanent location.
- Path structure: Files are organized as
disk://products/1/images/filename.jpg
. - File deletion: When a file is removed from a model attribute, it is deleted from the disk.
- Model delete: When a model is deleted, all associated files and their thumbnails are automatically removed.
- Rich text processing: Files referenced in rich text fields are automatically managed.
- Thumbnail management: When enabled, thumbnails are automatically created for images and cleaned up when originals are removed.
Example usage
Thumbnail generation
The package automatically generates thumbnails for image files when enabled in the config. Thumbnails are created during file moves and automatically cleaned up when the original files are deleted.
When enabled, uploading an image will automatically create a thumbnail alongside the original:
- Original:
products/1/images/photo.jpg
- Thumbnail:
products/1/images/photo-thumb.jpg
Thumbnails are automatically managed: when you delete or replace the original image, the corresponding thumbnail is also removed.
File Cleanup
You may schedule the CleanOrphanedUploads
job by following Laravel's documentation on scheduling jobs.
Configuration
The package supports extensive configuration options. Here are the key settings:
Testing
Changelog
Please see CHANGELOG for more information on what has changed recently.
Credits
- Chris Seidl
- All Contributors
License
The MIT License (MIT). Please see License File for more information.
All versions of laravel-auto-filer with dependencies
christopheraseidl/circuit-breaker Version ^0.4.1
illuminate/contracts Version ^10.0||^11.11||^12.0
intervention/image-laravel Version ^1.5
spatie/laravel-package-tools Version ^1.16