PHPackages                             libratechie/think-filesystem - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [File &amp; Storage](/categories/file-storage)
4. /
5. libratechie/think-filesystem

ActiveLibrary[File &amp; Storage](/categories/file-storage)

libratechie/think-filesystem
============================

ThinkPHP flysystem package

v1.0.0(1y ago)116MITPHPPHP &gt;=8.2

Since Aug 8Pushed 1y ago1 watchersCompare

[ Source](https://github.com/libratechie/think-filesystem)[ Packagist](https://packagist.org/packages/libratechie/think-filesystem)[ RSS](/packages/libratechie-think-filesystem/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (1)Dependencies (4)Versions (2)Used By (0)

ThinkPHP flysystem package
==========================

[](#thinkphp-flysystem-package)

This is a filesystem extension package for ThinkPHP 8.0, supporting local file storage, Qiniu OSS storage, and Aliyun OSS storage (Aliyun). This package seamlessly integrates with ThinkPHP, providing a robust and flexible solution for managing file storage across multiple storage backends. With this package, developers can easily switch between different storage options, ensuring efficient and reliable file handling in their applications. Future versions of this package will include support for additional storage systems, further enhancing its versatility and functionality.

Requirement
-----------

[](#requirement)

- `PHP` &gt;= 8.2
- `league/flysystem` ^3.28

Installation
------------

[](#installation)

```
$ composer require libratechie/think-filesystem
```

Usage
-----

[](#usage)

### Method 1: Using Direct Class Reference

[](#method-1-using-direct-class-reference)

You can directly reference the Filesystem class provided by the package. This approach allows you to use the disk method to specify which disk you want to work with:

```
use \Libratechie\Think\Filesystem;
$disk = Filesystem::disk('public');
```

### Method 2: Using ThinkPHP Container Resolution

[](#method-2-using-thinkphp-container-resolution)

Alternatively, you can leverage ThinkPHP's container to resolve the filesystem service. This method is useful when you want to adhere to dependency injection principles and make your code more testable:

```
$disk = app('filesystem')::disk('qiniu');
```

Configuration
-------------

[](#configuration)

### Local

[](#local)

```
return [
    'disks'   => [
        //...
        'local'  => [
            'type' => 'local',
            'root' => app()->getRuntimePath() . 'storage',
        ],
        'public' => [
            'type'       => 'local',
            'root'       => app()->getRootPath() . 'public/storage',
            'url'        => '/storage',
            'visibility' => 'public',
        ],
        //...
    ],
];
```

### Aliyun

[](#aliyun)

```
return [
    'disks'   => [
        //...
        'aliyun' => [
            'type'            => 'aliyun',
            'accessKeyId'     => '',
            'accessKeySecret' => '',
            'bucket'          => '',
            'endpoint'        => '',
            // 'domain'       => 'bucket.oss-cn-guangzhou.aliyuncs.com',
            // or with protocol: https://bucket.oss-cn-guangzhou.aliyuncs.com
        ]
        //...
    ],
];
```

> Domain Configuration： The domain configuration specifies the external access path for your Alibaba Cloud OSS resources. By default, using the OSS default domain to access HTML or image resources may result in them being downloaded as attachments. To allow direct access via a web browser, you need to use a custom domain.

### Qiniu

[](#qiniu)

```
return [
    'disks'   => [
        //...
        'qiniu'  => [
            'type'      => 'qiniu',
            'accessKey' => '',
            'secretKey' => '',
            'bucket'    => '',
            'domain'    => 'xxxxx.hn-bkt.clouddn.com',
            // or with protocol: https://xxxxx.hn-bkt.clouddn.com
        ],
        //...
    ],
];
```

API
---

[](#api)

```
// Write files
$folderPath = '/path/to';
$file = request()->file('file');

// Use the default naming convention to write the file
$fileName = $disk->putFile($folderPath, $file);
// $fileName: /path/to/20240725/2697c763c84fe48d0166d0cd37181e19.jpg

// Use SHA-256 hash as the file name
$fileName = $disk->putFile($folderPath, $file, 'sha256');
// $fileName: /path/to/55/fd6b615cb02ce73c8e708ac62c9fe9c0cdd92d9161c57186e592d2b672e6e3.jpg

// Use a custom callback function to generate the file name
$fileName = $disk->putFile($folderPath, $file, function ($fileHash) {
    return 'custom' . DIRECTORY_SEPARATOR . md5($fileHash->getPathname());
});
// $fileName: /path/to/custom/db8fbf2c977c3fae6276521f788d5183.jpg
```

```
// Save the file with a specified file name
$fileName = $disk->putFileAs($folderPath, $file, 'custom.txt');
```

```
// Check whether a file exists.
$exists = $disk->fileExists('/path/to/custom.txt');
```

```
// Get file access path.
$exists = $disk->url('/path/to/custom.txt');
```

```
// Get file size.
$size = $disk->fileSize('/path/to/custom.txt');
```

```
// Get file mimeType.
$size = $disk->mimeType('/path/to/custom.txt');
```

```
// Copy files
$disk->copy('/path/to/file.txt', '/path/to/copy_file.txt');
```

```
// Move files
$disk->move('/path/to/custom.txt', '/path/to/moved_file.txt');
```

```
// Delete files
$disk->delete('/path/to/file.txt');
```

###  Health Score

28

—

LowBetter than 54% of packages

Maintenance34

Infrequent updates — may be unmaintained

Popularity7

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity52

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 71.4% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

646d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/3fa85c5a3c02014f51ff2f57c9f5f1b9e230a6400422a231e200271726fa0584?d=identicon)[libratechie](/maintainers/libratechie)

---

Top Contributors

[![libratechie](https://avatars.githubusercontent.com/u/23713970?v=4)](https://github.com/libratechie "libratechie (5 commits)")[![StyleCIBot](https://avatars.githubusercontent.com/u/11048387?v=4)](https://github.com/StyleCIBot "StyleCIBot (2 commits)")

### Embed Badge

![Health badge](/badges/libratechie-think-filesystem/health.svg)

```
[![Health](https://phpackages.com/badges/libratechie-think-filesystem/health.svg)](https://phpackages.com/packages/libratechie-think-filesystem)
```

###  Alternatives

[league/flysystem-aws-s3-v3

AWS S3 filesystem adapter for Flysystem.

1.6k263.6M790](/packages/league-flysystem-aws-s3-v3)[unisharp/laravel-filemanager

A file upload/editor intended for use with Laravel 5 to 10 and CKEditor / TinyMCE

2.2k3.3M74](/packages/unisharp-laravel-filemanager)[league/flysystem-sftp-v3

SFTP filesystem adapter for Flysystem.

6129.6M91](/packages/league-flysystem-sftp-v3)[overtrue/laravel-filesystem-qiniu

A Qiniu storage filesystem for Laravel.

482229.7k16](/packages/overtrue-laravel-filesystem-qiniu)[yii2-starter-kit/yii2-file-kit

Yii2 file upload and storage kit

151216.8k6](/packages/yii2-starter-kit-yii2-file-kit)[azure-oss/storage-blob-flysystem

Flysystem adapter for Azure Storage PHP

29936.0k10](/packages/azure-oss-storage-blob-flysystem)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
