arne-groskurth / temp-file
此包已被弃用,不再维护。未建议替代包。
TempFile 是一个受 SplTempFileObject 启发的小型库,为处理临时文件时遇到的常见任务提供解决方案。
1.5.0
2021-10-24 12:33 UTC
Requires
- php: ^5.4 || ^7.0 || ^8.0
- ext-fileinfo: *
- symfony/http-foundation: ^3.1 || ^4.0 || ^5.0
Requires (Dev)
- phpunit/phpunit: ^5.5 || ^9.3.0
- roave/security-advisories: dev-latest
README
TempFile 是一个受 SplTempFileObject 启发的库,为处理临时文件时遇到的常见任务提供解决方案。
安装
$ composer require arne-groskurth/temp-file
使用
<?php use ArneGroskurth\TempFile\TempFile; $tempFile = new TempFile(); // TempFile offers all commonly used file-related functions including fread, fwrite, ftell, fseek and feof. $tempFile->fwrite('Hello World!'); // Construct response object and write to stdout // (Requires installation of package "symfony/http-foundation") $tempFile->send(); // Obtain path-based access to temporary file within callback function $tempFile->accessPath(function($path) { $content = file_get_contents($path); $content = str_replace('Hello World!', 'Got you!', $content); file_put_contents($path, $content); }); // Echos 'Got yout!' print $tempFile->getContent(); // Persist temporary file to some path $tempFile->persist('/my/path/filename.ext');