danbettles / temper
Tame your temp files. Temper offers a smoother approach to working with temp files in PHP.
dev-main
2022-11-08 21:13 UTC
Requires
- php: ^7.4|^8.1.3
Requires (Dev)
- danbettles/codesniffer-standard: ^2.0
- phpunit/phpunit: ^9.5
- squizlabs/php_codesniffer: ^3.5
This package is auto-updated.
Last update: 2024-04-09 00:11:10 UTC
README
Temper offers a smoother approach to working with temp files in PHP.
Usage
There are two ways to use it:
- Consume a temp file: create, use, and remove a temp-file in a single operation.
- Create and remove temp-files in separate steps.
Consume a Temp File
$temper = new Temper('/path/to/tmp/dir'); $temper->consumeFile(function (string $tempFilePathname): void { // Do something with temp file. }); // Temp file gone. $temper->consumeFile(function (string $tempFilePathname): void { // Do something with `.jpg` temp file. }, 'jpg'); // Temp file gone.
Create and Remove In Separate Steps
$temper = new Temper('/path/to/tmp/dir'); $tempFilePathnameWithoutExtension = $temper->createFile(); $tempImageFilePathname = $temper->createFile('jpg'); // Removes all remaining temp-files created by the Temper instance. $temper->cleanUp();
Installation
Install using Composer:
composer require danbettles/temper