Download the PHP package vldmir/laravel-temp-file-manager without Composer
On this page you can find all versions of the php package vldmir/laravel-temp-file-manager. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download vldmir/laravel-temp-file-manager
More information about vldmir/laravel-temp-file-manager
Files in vldmir/laravel-temp-file-manager
Package laravel-temp-file-manager
Short Description A Laravel package for managing temporary files with automatic cleanup
License MIT
Informations about the package laravel-temp-file-manager
Laravel Temporary File Manager
A Laravel package for managing temporary files with automatic cleanup functionality. This package helps you manage temporary files in your Laravel application with features like automatic cleanup, file registration, and scheduled deletion of old files.
Features
- ๐ Easy temporary file management
- ๐พ Multiple methods for saving temporary files
- ๐งน Automatic cleanup of old files
- ๐๏ธ Auto-deletion of registered files after process completion
- โ๏ธ Configurable storage location and retention period
- ๐ฆ Laravel integration with Facade support
- ๐ Scheduled cleanup command
- ๐ช Strong typing and modern PHP 8.0+ features
Requirements
- PHP 8.0 or higher
- Laravel 8.0 or higher
Installation
You can install the package via composer:
Configuration
Publish the configuration file:
This will create a temp-file-manager.php
config file in your config directory. You can modify these settings:
Usage
Saving Files
The package provides several methods to save files to temporary storage:
1. Save String Content
2. Save Uploaded Files
3. Save From URL
4. Save Stream/Resource
File Cleanup Behavior
There are three ways files can be cleaned up:
-
Automatic Cleanup After Process (Using register)
-
Manual Cleanup (Using cleanup method)
- Scheduled Cleanup (For old files)
Scheduled Cleanup Command
To automatically clean up old temporary files, register the cleanup command in your App\Console\Kernel
:
Dependency Injection Usage
You can also use dependency injection to access the TempFileManager:
Complete Example in Controller
File Naming Behavior
When saving files, the package handles filenames in the following way:
- If no filename is provided, a random name is generated
- If a filename is provided:
- Unsafe characters are removed from the filename
- If a file with the same name exists, a counter is appended (e.g.,
file_1.txt
,file_2.txt
)
The filename sanitization process:
- Removes any character that isn't alphanumeric, dot, dash, or underscore
- Replaces multiple consecutive dots/underscores with a single one
- Removes dots and dashes from the start and end of the filename
- Ensures the filename isn't empty
Changelog
Please see CHANGELOG for more information on what has changed recently.
Contributing
Please see CONTRIBUTING for details.
Security
If you discover any security-related issues, please email [email protected] instead of using the issue tracker.
Credits
- Vladimir
- All Contributors
License
The MIT License (MIT). Please see License File for more information.