承接 ajgl/flysystem-cow 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

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

ajgl/flysystem-cow

Composer 安装命令:

composer require ajgl/flysystem-cow

包简介

Flysystem Copy-On-Write (COW) adapter

README 文档

README

Latest Stable Version Total Downloads License QA checks

Flysystem Copy-On-Write (COW) Adapter is a library that provides a copy-on-write mechanism for Flysystem adapters. It allows you to manage a layered filesystem where changes are written to a "top" layer while preserving the integrity of a "base" layer.

Features

  • Copy-On-Write Mechanism: Changes are written to a top layer, leaving the base layer untouched.
  • Integration with Flysystem: Fully compatible with Flysystem v3.
  • Public and Temporary URLs: Supports generating public and temporary URLs when the underlying adapters support it.

Installation

Install the library using Composer:

composer require ajgl/flysystem-cow

Usage

<?php

require 'vendor/autoload.php';

use Ajgl\Flysystem\Cow\CowFilesystemAdapter;
use League\Flysystem\Config;
use League\Flysystem\InMemory\InMemoryFilesystemAdapter;

// Base adapter (read-only)
$baseAdapter = new InMemoryFilesystemAdapter();
$baseAdapter->write('example.txt', 'Hello, World!', new Config());

// Optional top adapter (write layer)
$topAdapter = new InMemoryFilesystemAdapter();

// Create the COW adapter
$cowAdapter = new CowFilesystemAdapter($baseAdapter, $topAdapter);

// Base file overwriting
$cowAdapter->write('example.txt', 'Hello, Planet!', new Config());
echo $cowAdapter->read('example.txt'); // Outputs: Hello, Planet!
echo PHP_EOL;

echo $baseAdapter->read('example.txt'); // Outputs: Hello, World!
echo PHP_EOL;

echo $topAdapter->read('example.txt'); // Outputs: Hello, Planet!
echo PHP_EOL;

// Base file deletion
$cowAdapter->delete('example.txt');
echo $cowAdapter->fileExists('example.txt') ? 'Yes' : 'No'; //Outputs: No
echo PHP_EOL;

echo $baseAdapter->fileExists('example.txt') ? 'Yes' : 'No'; //Outputs: Yes
echo PHP_EOL;

echo $topAdapter->fileExists('example.txt') ? 'Yes' : 'No'; //Outputs: No
echo PHP_EOL;

License

This project is licensed under the MIT License.

Acknowledgments

This library is built on top of the excellent Flysystem library by @frankdejonge.

Made with ❤️ by Antonio J. García Lagar.

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2025-05-30

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固