This plugins provides class for creating temporary files, that are guaranteed to be deleted after program termination,
and is compatible with CakePHP\Filesystem\File
API.
Create unique temporary files:
$tmpFile1 = new TmpFile();
$tmpFile2 = new TmpFile(
'foo-',
TMP . 'bar',
0644
)
$tmpFile2->close();
// use as a regular CakePHP\Filesystem\File
$tmpfile->open()
$tmpfile->write($data);
$tmpfile->close();
After a program termination (regular or after a crash) the file will be deleted.
Constructor's parameters:
string $prefix The prefix of the generated temporary filename.
string $path The directory where the temporary filename will be created
int $mode File permissions
You can install this plugin into your CakePHP application using composer.
The recommended way to install composer packages is:
composer require dmromanov/cakephp-tmpfile