plugse / fileandpath
一个辅助编写和读取文档的库。
1.0.0
2023-05-19 14:27 UTC
Requires
- php: >=7.4
Requires (Dev)
- phpunit/phpunit: ^9
README
简化保存和读取数据到文件的方式
菜单
作为依赖安装
使用Composer安装File and Path
直接通过Composer
composer require plugse/fileandpath
修改composer.json文件
- 创建或修改composer.json文件
- 创建或修改require属性
{ "require": { "plugse/fileandpath": "^1" } }
- 使用以下命令更新库
composer update
运行测试
要运行测试,请执行以下命令
composer run-script post-install-cmd
功能
- 如果不存在,则创建路径
File::createPathIfNotExists( string $path ): void
- 将数组保存到JSON文件
Json::Save( string $filename, array $dataStructure ): void
- 将数组保存到.ENV文件
Env::save( string $filename, array $dataStructure ): void
- 将数组保存到LOG文件
Log::save( string $filename, array $dataStructure ): void
- 读取JSON文件并返回内容为数组
Json::read( string $filename ): array
- 读取.ENV文件并返回内容为数组
Env::read( string $filename ): array
- 读取LOG文件并返回内容为数组
Log::read( string $filename ): array
异常
-
FileAlreadyExists
-
FileNotFound