PHPackages                             windwork/storage - 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. windwork/storage

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

windwork/storage
================

windwork storage components

0.7.0(8y ago)0741MITPHPPHP &gt;=5.5.0

Since May 24Pushed 8y agoCompare

[ Source](https://github.com/windwork/wf-storage)[ Packagist](https://packagist.org/packages/windwork/storage)[ RSS](/packages/windwork-storage/feed)WikiDiscussions master Synced 2w ago

READMEChangelog (4)DependenciesVersions (5)Used By (1)

Windwork 附件存贮组件
===============

[](#windwork-附件存贮组件)

为兼容本地存贮和第三方云存贮平台或存贮系统，特封装存贮组件

安装
--

[](#安装)

该组件已包含在Windwork框架中，如果你已安装Windwork框架则可以直接使用。

- 安装方式一：通过composer安装（推荐）

```
composer require windwork/wf

```

- 安装方式二：传统方式安装
    [下载源码](https://github.com/windwork/wf/releases)后，解压源码到项目文件夹中，然后require\_once $PATH\_TO\_WF/core/lib/Loader.php文件，即可自动加载组件中的类。

使用方法
----

[](#使用方法)

```
1. 在 config/app.php 中设置 srv.storage 组件参数
2. 调用实例方法 wfStorage()->xxx()

```

配置参数
----

[](#配置参数)

```
$cfg = [
    'class'      => '\\wf\\storage\\adapter\\File',          // 附件处理 adapter
    'dir'        => 'storage',       // 附件存贮文件夹，相对于站点根目录
    'storageUrl' => 'storage',       // 附件目录url，格式：http://www.windwork.org/storage/（后面带'/'，如果附件访问网址跟附件上传站点不是同一个站时设置）
    'sizeLimit'  => '2048',          // (M)文件上传大小限制
];

```

创建实例
----

[](#创建实例)

```
// 通过工厂方法创建实例
$class = {$cfg['class']};
$stor = new $class($cfg);

// 通过函数创建

// 函数定义在 wf/web/lib/helper.php
//function wfStorage() {
//    return wfStorage();
//}

$stor = wfStorage();

```

thumb 函数
--------

[](#thumb-函数)

生成存储系统中缩略图的链接

```
/**
 * 获取缩略图的URL，一般在模板中使用
 * @param string|ing $path 图片路径或图片附件id
 * @param int $width = 100 为0时按高比例缩放
 * @param int $height = 0 为0时按宽比例缩放
 * @return string
 */
function thumb($path, $width = 100, $height = 0) {
    return wfStorage()->getThumbUrl($path, $width, $height);
}

```

storageUrl 函数
-------------

[](#storageurl-函数)

```
/**
 * 根据上传文件的Path获取完整URL
 * @param string $path
 * @return string
 */
function storageUrl($path) {
    return wfStorage()->getFullUrl($path);
}

```

storagePath 函数
--------------

[](#storagepath-函数)

```
/**
 * 根据上传文件的URL获取Path
 * @param string $url
 * @return string
 */
function storageUrl($url) {
    return wfStorage()->getPathFromUrl($url);
}

```

### 要了解更多？

[](#要了解更多)

> - [官方完整文档首页](http://docs.windwork.org/manual/)
> - [官方源码首页](https://github.com/windwork)

###  Health Score

24

—

LowBetter than 31% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity9

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity51

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% 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

Every ~11 days

Total

4

Last Release

3283d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/24246959?v=4)[Windwork](/maintainers/windwork)[@windwork](https://github.com/windwork)

---

Top Contributors

[![cmpan](https://avatars.githubusercontent.com/u/399927?v=4)](https://github.com/cmpan "cmpan (21 commits)")

### Embed Badge

![Health badge](/badges/windwork-storage/health.svg)

```
[![Health](https://phpackages.com/badges/windwork-storage/health.svg)](https://phpackages.com/packages/windwork-storage)
```

###  Alternatives

[venveo/craft-compress

Create smart zip files from Craft assets on the fly

124.7k](/packages/venveo-craft-compress)

PHPackages © 2026

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