承接 amedev/file-manager 相关项目开发

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

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

amedev/file-manager

最新稳定版本:1.0.3

Composer 安装命令:

composer require amedev/file-manager

包简介

Laravel File Manager Package

README 文档

README

FileManager is a Laravel package for polymorphic file management.
It provides a centralized API for uploading files and attaching them to any model, with support for multiple storage disks and dynamic model resolution.

📦 Installation

Install the package via Composer:

composer require amedev/file-manager

php artisan vendor:publish --tag=config
php artisan vendor:publish --tag=file-manager-migrations
php artisan vendor:publish --tag=file-manager-models

php artisan migrate

⚙️ Configuration
File: config/filemanager.php

return [

    /*
    |--------------------------------------------------------------------------
    | Default Storage Disk
    |--------------------------------------------------------------------------
    | Supported options: 'local', 'public', 'sftp'
    */
    'disk' => env('FILE_MANAGER_DISK', 'sftp'),

    /*
    |--------------------------------------------------------------------------
    | Default Upload Path
    |--------------------------------------------------------------------------
    */
    'default_path' => 'uploads',

    /*
    |--------------------------------------------------------------------------
    | Model Map
    |--------------------------------------------------------------------------
    | Maps model aliases to actual class names.
    | Used for polymorphic file attachment.
    */
    'model_map' => [
        'user' => \App\Models\User::class,
        // Add more models as needed
    ],
];

🧪 API Usage
Upload Files

POST /filemanager/upload
Content-Type: multipart/form-data

fields:
- model_type: user
- model_id: 5
- files[]: (multiple files)



[
  {
    "id": 1,
    "path": "uploads/user/files/abc123.png",
    "mime_type": "image/png",
    "size": 31200,
    "field": "files"
  },
  ...
]

🧬 Polymorphic Relation
The File model uses a morphTo relation:

public function fileable()
{
    return $this->morphTo();
}


🛠 Artisan Commands
Fix Model Namespace

php artisan file-manager:fix-model-namespace

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2025-08-04