tourze / symfony-request-file-clean-bundle
Installs: 4
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 0
Open Issues: 0
Type:symfony-bundle
Requires
- php: >=8.1
- symfony/framework-bundle: ^6.4
- symfony/http-foundation: ^6.4
This package is auto-updated.
Last update: 2025-03-31 00:31:16 UTC
README
A Symfony bundle that automatically cleans up temporary uploaded files after request completion in special environments where the system doesn't automatically remove them.
Features
- Automatically removes temporary uploaded files after request completion
- Works with both array-style file uploads and UploadedFile objects
- High priority event listener ensures cleanup happens after all other processes
- Zero configuration required
Installation
Install the bundle using Composer:
composer require tourze/symfony-request-file-clean-bundle
Quick Start
There's no configuration required. The bundle automatically registers the event subscriber that handles the file cleanup after request termination.
If you're using Symfony Flex, the bundle will be automatically registered. If not, you need to add it to your config/bundles.php
:
<?php return [ // ... Tourze\RequestFileCleanBundle\RequestFileCleanBundle::class => ['all' => true], ];
How It Works
The bundle registers an event subscriber that listens to the KernelEvents::TERMINATE
event with a very low priority (-9999). When the request terminates, it iterates through all uploaded files in the request and properly removes the temporary files from the filesystem.
This helps prevent file system bloat in environments where temporary files aren't automatically cleaned up by the system.
Requirements
- PHP 8.1 or higher
- Symfony 6.4 or higher
Contributing
Contributions are welcome! Feel free to submit a Pull Request.
License
This bundle is released under the MIT License. See the License File for more information.