spatie/temporary-directory
Create, use, and automatically clean up temporary directories in PHP. Spatie TemporaryDirectory makes it easy to generate a temp folder (in your system temp path), build file paths inside it, and delete everything when you’re done.
Adopt if:
sys_get_temp_dir() + manual rmdir() calls./mnt/tmp instead of /tmp).->create()->path('file.txt')->delete()).Look elsewhere if:
Storage facade or AWS S3 instead).tmpfile() or sys_tempfile().EncryptedTemporaryFilesystem or similar).For Executives: *"This package lets our Laravel/PHP apps handle temporary files automatically and safely—like a self-cleaning trash can for data processing. It’s used by [X] teams to:
composer require."*For Engineers:
*"Spatie’s temporary-directory is a drop-in replacement for hacky temp-file logic. Key wins:
TemporaryDirectory::make()->create()->path('file.txt')->delete().deleteWhenDestroyed() to auto-delete when the object goes out of scope (PHP 8+).0755), paths, or force-overwrite existing dirs./tmp.
Example use case: Processing user uploads in a queue job—temp files auto-delete after conversion. No more rm -rf in your scripts."*How can I help you explore Laravel packages today?