国产+高潮+在线,国产 av 仑乱内谢,www国产亚洲精品久久,51国产偷自视频区视频,成人午夜精品网站在线观看

laravel-filesystem 文件系統(tǒng)

3.1.x-dev 版本
2025-03-17 版本更新時(shí)間
2315 安裝
5 star

webman-tech/laravel-filesystem

Laravel illuminate/filesystem for webman

介紹

站在巨人(laravel)的肩膀上使文件存儲使用更加可靠便捷

所有方法和配置與 laravel 幾乎一模一樣,因此使用方式完全參考 Laravel文檔 即可

安裝

由于 laravel 9 升級了 league/flysystem 到 3.x,詳見Laravel9升級說明
,低于 larval 9 的版本需要使用 league/flysystem 1.x 的版本
,因此安裝該依賴需要手動安裝 illuminate/filesystemleague/flysystem

  1. 安裝 webman-tech/laravel-filesystem
composer require webman-tech/laravel-filesystem
  1. 安裝 league/flysystem

根據(jù) illuminate/filesystem 安裝后的版本(通過 composer info illuminate/filesystem 查看)

# illuminate/filesystem < 9.0
composer require league/flysystem:~1.1
# illuminate/filesystem >= 9.0
composer require league/flysystem

使用

所有 API 同 laravel,以下僅對有些特殊的操作做說明

目錄權(quán)限問題

Unix 系統(tǒng)下需要給予 storage/app 目錄寫權(quán)限

Facade 入口

使用 WebmanTech\LaravelFilesystem\Facades\File 代替 Illuminate\Support\Facades\File

使用 WebmanTech\LaravelFilesystem\Facades\Storage 代替 Illuminate\Support\Facades\Storage

建立軟鏈

php webman storage:link

建立軟鏈之后建議將軟鏈(如 /public/storage)加入根目錄下的 .gitignore

同 Laravel,可以支持自定義建立多個(gè)對外的路勁軟鏈

Request 文件上傳

原 Laravel 下通過 $request()->file() 之后的快捷文件操作,需要使用 webman-tech/polyfill 來支持

安裝

composer require webman-tech/polyfill illuminate/http

使用

<?php

namespace app\controller;

use support\Request;
use WebmanTech\Polyfill\LaravelRequest;
use WebmanTech\Polyfill\LaravelUploadedFile;

class UserAvatarController
{
    public function update(Request $request)
    {
        $path = LaravelRequest::wrapper($request)->file('file')->store('avatars');
        // 或者
        $path = LaravelUploadedFile::wrapper($request->file('avatar'))->store('avatars');

        return response($path);
    }
}

自定義文件系統(tǒng)

通過在 filesystems.php 配置文件的 extends 中添加驅(qū)動(驅(qū)動可以通過實(shí)現(xiàn) WebmanTech\LaravelFilesystem\Extend\ExtendInterface 來快速創(chuàng)建),
然后在 disks 中添加對應(yīng)的實(shí)例即可

目前提供以下非 Laravel 官方庫支持的文件系統(tǒng),可自行參考替換相應(yīng)的實(shí)現(xiàn)

Aliyun OSS

使用 iidestiny/flysystem-oss

# illuminate/filesystem < 9.0
composer require iidestiny/flysystem-oss:~2.7
# illuminate/filesystem >= 9.0
composer require iidestiny/flysystem-oss

QiNiu

使用 overtrue/flysystem-qiniu

# illuminate/filesystem < 9.0
composer require overtrue/flysystem-qiniu:~1
# illuminate/filesystem >= 9.0
composer require overtrue/flysystem-qiniu

Tencent COS

使用 overtrue/flysystem-cos

# illuminate/filesystem < 9.0
composer require overtrue/flysystem-cos:~3
# illuminate/filesystem >= 9.0
composer require oovertrue/flysystem-cos
贊助商