csfcloud / utils
此包已被废弃且不再维护。未建议替代包。
常用类和函数的Utils包
dev-master
2018-10-21 10:20 UTC
Requires
- php: ^7.0
- microsoft/azure-storage-blob: ^1.2
Requires (Dev)
- phpunit/phpunit: ~7.1.5
This package is auto-updated.
Last update: 2021-04-11 16:59:14 UTC
README
内容
- 临时文件管理器
- 命令执行器
- 递归文件列表器
临时文件管理器
创建新的临时文件
use CSFCloud\TempFiles\TempManager; $tmp = new TempManager("my_context"); // Create a context $file = $tmp->createFile(); // Create a new file $file_path = $file->getPath(); // Get the full path to the file $id = $file->getId(); // Get the file id, to access this file in an other session
加载现有临时文件
use CSFCloud\TempFiles\TempManager; $tmp = new TempManager("my_context"); // Create a context $file = $tmp->getFile("my_file_id"); // Load the file with the file id
命令执行器
运行命令
use CSFCloud\Shell\CommandRunner; $runner = new CommandRunner(); $output_file = $runner->run(CommandRunner::COMMAND_SYNC, __DIR__, "ls"); echo $output_file->getText(); $output_file->delete();
递归文件查找器
在目录中递归查找文件
use CSFCloud\RecursiveFileListing; $finder = new RecursiveFileListing(__DIR__ . "/my_directory"); $files = $finder->scan(); var_dump($files);
在目录中递归查找txt文件
use CSFCloud\RecursiveFileListing; $finder = new RecursiveFileListing(__DIR__ . "/my_directory"); $finder->addFilter('/.*\.txt$/i'); $files = $finder->scan(); var_dump($files);