plugse/fileandpath

一个辅助编写和读取文档的库。

1.0.0 2023-05-19 14:27 UTC

This package is auto-updated.

Last update: 2024-09-19 13:02:18 UTC


README

Logo

GitHub release (release name instead of tag name) GitHub PHP PHP Unit

简化保存和读取数据到文件的方式

菜单

作为依赖安装

使用Composer安装File and Path

直接通过Composer

  composer require plugse/fileandpath

修改composer.json文件

  1. 创建或修改composer.json文件
  2. 创建或修改require属性
{
    "require": {
        "plugse/fileandpath": "^1"
    }
}
  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