sentgine/file 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

sentgine/file

最新稳定版本:v1.1.1

Composer 安装命令:

composer require sentgine/file

包简介

A simple wrapper around file system operations.

README 文档

README

License Latest Stable Version Total Downloads

File is a PHP library that provides a simple wrapper around file system operations.

Features

  • Create, read, update, and delete files.
  • Create directories if they do not exist.
  • Replace placeholders in a source file and write the modified content to a destination file.
  • Remove directories and all their contents recursively.

Requirements

  • PHP 8.0 or higher.

Installation

You can install the package via Composer by running the following command:

composer require sentgine/file:^1.0

Sample Usage of Filesystem

Basic Usage

use Sentgine\File\Filesystem;

// Create a new instance of the Filesystem class
$fileSystem = new Filesystem();

// Set source and destination files
$fileSystem->setSourceFile('path/to/source/file.txt')
           ->setDestinationFile('path/to/destination/file.txt');

// Read content from the source file
$content = $fileSystem->read();

// Update content in the destination file
$fileSystem->update('New content');

// Delete the destination file
$fileSystem->delete();

Usage of replaceContent

use Sentgine\File\Filesystem;

// Create a new instance of the Filesystem class
$fileSystem = new Filesystem();

 // Get the content of the file.text file
$content = $filesystem->setSourceFile('/source/directory/file.text')->read();

// Create a new directory if it doesn't exist
$filesystem->createDirectory('/source/new_directory');

// Write the content to the Controller file
$filesystem->setDestinationFile('/source/new_directory/new_file.text')->create($content);

// Replace the content of the destination file
$filesystem->replaceContent(
    replacements: [
       'placeholder1' => 'replacement1',
        'placeholder2' => 'replacement2',
    ]
);

The destination file (path/to/source/file.txt) should contain placeholders formatted as {{ placeholder }}, as shown in the example below:

Hello {{ placeholder1 }},

This is a sample file with placeholders. Here is the value of placeholder2: {{ placeholder2 }}.

Thank you!

Changelog

Please see the CHANGELOG file for details on what has changed.

Security

If you discover any security-related issues, please email sentgine@gmail.com instead of using the issue tracker.

Credits

File is built and maintained by Adrian Navaja.

  • Check out some cool tutorials and stuff on YouTube!
  • Catch my latest tweets and updates on Twitter (formerly X)!
  • Let's connect on a more professional note over on LinkedIn!
  • For more information about me and my work, visit my website: sentgine.com.

License

The MIT License (MIT). Please see the LICENSE file for more information.

统计信息

  • 总下载量: 30
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 0
  • 依赖项目数: 1
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2024-04-12