Laravel illuminate/filesystem for webman

Overview

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

根据 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,以下仅对有些特殊的操作做说明

目录权限问题

Unix 系统下需要给予 storage/app 目录写权限

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,可以支持自定义建立多个对外的路劲软链

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);
    }
}

自定义文件系统

通过在 filesystems.php 配置文件的 extends 中添加驱动(驱动可以通过实现 WebmanTech\LaravelFilesystem\Extend\ExtendInterface 来快速创建), 然后在 disks 中添加对应的实例即可

目前提供以下非 Laravel 官方库支持的文件系统,可自行参考替换相应的实现

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
You might also like...
Laravel Podcast Manager is a complete podcast manager package for Laravel 5.3+ that enables you to manage RSS feeds for your favorite podcasts and listen to the episodes in a seamless UI.
Laravel Podcast Manager is a complete podcast manager package for Laravel 5.3+ that enables you to manage RSS feeds for your favorite podcasts and listen to the episodes in a seamless UI.

laravelpodcast | A Laravel podcast manager package - v0.0.8 Introduction Laravel Podcast Manager is a complete podcast manager package for Laravel 5.3

Laravel-htaccess - a package for dynamically edit .htaccess in laravel

laravel-htaccess a package for dynamically edit .htaccess in laravel use RedirectHtaccess Facade function for add RedirectHtaccess()-add(); return in

Laravel & Google Drive Storage - Demo project with Laravel 6.x and earlier

Laravel & Google Drive Storage Demo project with Laravel 8.X Look at the commit history to see each of the steps I have taken to set this up. Set up t

Empower your business to accept payments globally, earn rewards and invest in crypto with lazerpay laravel sdk in your laravel project.
Empower your business to accept payments globally, earn rewards and invest in crypto with lazerpay laravel sdk in your laravel project.

Lazerpay Laravel Package pipedev/lazerpay is a laravel sdk package that access to laravel api Installation PHP 5.4+ and Composer are required. To get

Laravel package for Mailjet API V3 and Laravel Mailjet Mail Transport

Laravel Mailjet Laravel package for handling Mailjet API v3 using this wrapper: https://github.com/mailjet/mailjet-apiv3-php It also provides a mailje

Laravel 9 Template - Just a empty Laravel 9 project, ready to start new crap.

Laravel 9 Template Just a empty Laravel 9 project, ready to start new crap. Clone and start using. Usage - Local Env The same as usual with laravel. C

Laravel Larex lets you translate your whole Laravel application with a single CSV file.
Laravel Larex lets you translate your whole Laravel application with a single CSV file.

Laravel Larex Laravel Larex lets you translate your whole Laravel application with a single CSV file. You can import translation entries from lang fol

Laravel Nova integration for justbetter/laravel-magento-customer-prices

Laravel Magento Customer Prices Nova Laravel Nova integration for justbetter/laravel-magento-customer-prices. Installation Install the package. compos

Laravel Nova integration for justbetter/laravel-magento-prices

Laravel Magento Prices Nova This package is the Laravel Nova integration for justbetter/laravel-magento-prices. Installation Install the package. comp

Comments
  • 对象存储的文件如何下载?

    对象存储的文件如何下载?

    我在filesystems.php中把七牛云设置default
    文件上传时可以正常上传, 但是使用download和url方法却提示 Call to undefined method League\Flysystem\Filesystem::download Storage::url($file) Storage::download($file)

    请问是不支持对象存储文件的下载和url获取吗?

    question 
    opened by iYting 5
  • 文件上传报错

    文件上传报错

    根据教程调用报错LaravelUploadedFile::wrapper($request->file('avatar'))->store('avatars') 报错信息: Webman\Exception\NotFoundException: Class 'Illuminate\Contracts\Filesystem\Factory' not found in /chancemall/webman/vendor/workerman/webman-framework/src/Container.php:36

    报错详细信息: https://www.workerman.net/q/9506

    opened by llocry 3
Releases(v3.0.0)
Owner
null
Webman quickly creates a verification code tool similar to Google verification code

webman-captcha-grid webman quickly creates a verification code tool similar to Google verification code webman 快速创建一个类似于 Google 点图验证码的本地验证码扩展 介绍 webma

听风吹雨 6 Dec 5, 2022
Very easy to use a current limiting component, the code is very simple, based on the webman framework.

Very easy to use a current limiting component, the code is very simple, based on the webman framework.

nsp-team 13 Dec 29, 2022
A lightweight queue based on Redis Stream for webman plugin.

workbunny/webman-rqueue ?? A lightweight queue based on Redis Stream for webman plugin. ?? A lightweight queue based on Redis Stream for webman plugin

workbunny 10 Dec 12, 2022
A PHP implementation of RabbitMQ Client for webman plugin.

workbunny/webman-rabbitmq ?? A PHP implementation of RabbitMQ Client for webman plugin. ?? A PHP implementation of RabbitMQ Client for webman plugin 常

workbunny 15 Dec 15, 2022
A Qiniu Storage filesystem for Laravel

Laravel filesystem Qiniu Qiniu storage for Laravel based on overtrue/flysystem-qiniu. Requirement PHP >= 5.5.9 Installation $ composer require "overtr

安正超 463 Dec 6, 2022
Egnyte Filesystem

Egnyte Filesystem I was working on Egnyte project for Laravel and didn't find any decent solution so decided to write my own. Inspired by Yespbs\Egnyt

null 2 Apr 27, 2022
Mage2click toolset to create and manage the Magento Docker development environment with mutagen.io file-sync for macOS and native filesystem mounts on Linux.

Mage2click - Magento Docker Toolset Mage2click toolset is a system-wide command-line tool for creating and managing simultaneously running Magento Doc

Mage2click 69 Nov 28, 2022
Laravel Blog Package. Easiest way to add a blog to your Laravel website. A package which adds wordpress functionality to your website and is compatible with laravel 8.

Laravel Blog Have you worked with Wordpress? Developers call this package wordpress-like laravel blog. Give our package a Star to support us ⭐ ?? Inst

Binshops 279 Dec 28, 2022
A Simple Linode SDK built for Laravel with @JustSteveKing laravel-transporter package

linode client A Simple Linode client built for Laravel with @JustSteveKing laravel-transporter package Installation You can install the package via co

Samuel Mwangi 2 Dec 14, 2022
A Laravel Wrapper for the Binance API. Now easily connect and consume the Binance Public & Private API in your Laravel apps without any hassle.

This package provides a Laravel Wrapper for the Binance API and allows you to easily communicate with it. Important Note This package is in early deve

Moinuddin S. Khaja 7 Dec 7, 2022