Download the PHP package tourze/symfony-temp-file-bundle without Composer
On this page you can find all versions of the php package tourze/symfony-temp-file-bundle. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download tourze/symfony-temp-file-bundle
More information about tourze/symfony-temp-file-bundle
Files in tourze/symfony-temp-file-bundle
Package symfony-temp-file-bundle
Short Description Symfony临时文件集中管理与自动清理bundle
License MIT
Informations about the package symfony-temp-file-bundle
symfony-temp-file-bundle
中文
Introduction
symfony-temp-file-bundle is a Symfony bundle for centralized management and automatic cleanup of temporary files.
It ensures that temporary files generated during HTTP requests or console commands are automatically deleted at the end of the process,
reducing the risk of leftover temp files.
Features
- Unified temporary file management: Centralized creation and deletion of temporary files
- Automatic cleanup: Files are automatically deleted at the end of HTTP requests and console commands
- Multiple event listeners: Supports
KernelEvents::TERMINATE,KernelEvents::EXCEPTION,ConsoleEvents::TERMINATE,ConsoleEvents::ERROR - Simple API: Easy-to-use methods for generating and managing temporary files
- Zero configuration: Works out of the box with minimal setup
- Memory efficient: Uses array shifting to manage file cleanup
Installation
Requirements
- PHP >= 8.1
- Symfony >= 6.4
Composer
Manual Registration (Symfony Flex will register automatically in most cases)
Add to config/bundles.php:
Quick Start
Generate a Temporary File
Register an Existing Temp File for Auto-Cleanup
Generate Temporary File Without Extension
API Documentation
TemporaryFileService
Methods
-
generateTemporaryFileName(string $prefix, ?string $ext = null): string- Generate a temporary file name with optional extension
- The file is automatically registered for cleanup
- Returns the full path to the temporary file
-
addTemporaryFile(string $file): void- Register an existing file for automatic cleanup
- Useful for files created outside the service
reset(): void- Manually clear the temporary file list
- Usually called automatically by event listeners
Event Listeners
The service automatically cleans up temporary files on these events:
KernelEvents::TERMINATE- Normal HTTP request terminationKernelEvents::EXCEPTION- HTTP request exceptionConsoleEvents::TERMINATE- Console command terminationConsoleEvents::ERROR- Console command error
Configuration
No configuration is required. The service is automatically registered and configured when the bundle is installed.
Contributing
- Issues and PRs are welcome
- Follow PSR-12 coding style
- Please ensure all PHPUnit tests pass before submitting
License
MIT License © tourze
Changelog
See [CHANGELOG.md] or Git commit history for details.
All versions of symfony-temp-file-bundle with dependencies
symfony/console Version ^7.3
symfony/dependency-injection Version ^7.3
symfony/event-dispatcher Version ^7.3
symfony/http-kernel Version ^7.3
symfony/property-access Version ^7.3
symfony/service-contracts Version ^3.6