keboola / php-temp
Temp library handles application temporary files
Installs: 376 537
Dependents: 31
Suggesters: 0
Security: 0
Stars: 0
Watchers: 18
Forks: 1
Open Issues: 0
pkg:composer/keboola/php-temp
Requires
- php: >=7.1
- symfony/filesystem: >2.8
Requires (Dev)
- infection/infection: ^0.12
- jakub-onderka/php-parallel-lint: ^1.0
- keboola/coding-standard: ^8.0
- phpstan/phpstan-shim: ^0.11
- phpunit/phpunit: ^7.0|^8.0
README
This library provides an isolated temporary folder for an application. The library has methods for generating randomly named folders and files.
Usage
use Keboola\Temp\Temp; $temp = new Temp('prefix'); // Creates a file with unique name suffixed by 'suffix' $tempFile = $temp->createTmpFile('suffix'); echo 'Files are stored in: ' . $temp->getTmpFolder(); $temp->remove();
Available methods:
getTmpFolder-- Get the name of the temporary folder.createFile-- Create a named file in the temporary folder.createTmpFile-- Create a random file in the temporary folder.
Migration from version 1.0
- The temp folder is no longer deleted automatically in the destructor. It needs to
be removed explicitly by calling the
remove()method. - The public
setIdmethod was removed. This function was rarely used and is no longer available. - The public
initRunFoldermethod was removed. The folder is now initialized when used and there is no need to callinitRunFolderany more. - The protected
getTmpPathmethod is now private.
License
MIT licensed, see LICENSE file.