PHP helper library for handling temporary files

dev-master 2013-12-12 15:26 UTC

This package is auto-updated.

Last update: 2024-05-15 11:38:53 UTC


Packagist | Twitter | Issues | Build Status

Eien is a small PHP helper library for handling temporary files. Get, create, make, remove and flush temporary files and directories. Currently unstable, work in progress.

Basic usage

Get a path to an available temporary file

echo (string) new Rah_Eien_Temporary_File();

Create a temporary file and move it to its final location once done

The file is moved to location specified with the optional Rah_Eien_File::$final option, if defined. The moving is performed once there are no other references to the instance, script is closed or when the move() method is called.

$tmp = new Rah_Eien_File();
$file = new Rah_Eien_Temporary_File($tmp);

If you want moving to happen automatically, the easiest ways are extending, which allows you to perform your actions within it, unsetting the instance once you are done with it or wrapping the instance to its own contexts, like an anonymous function.

Make a temporary file from an existing file

In addition to creating brand new temporary files, or getting paths as strings, you can also create temporary file instances from other files. The specified files are copied to your temporary directory, and you get an instance point to the new temporary instance.

$tmp = new Rah_Eien_File();
echo (string) new Rah_Eien_Temporary_File($tmp);

Create a new temporary directory and return its path

echo (string) new Rah_Eien_Temporary_Directory();