idkwhoami/flux-files 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

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

idkwhoami/flux-files

Composer 安装命令:

composer require idkwhoami/flux-files

包简介

A file manager based on FluxUI

README 文档

README

License: MIT Laravel PHP

A modern, elegant file manager package for Laravel applications built with FluxUI and Livewire. Provides a complete file management solution with drag-and-drop uploads, folder navigation, file selection components, and comprehensive file operations.

Features

  • 🗂️ File Browser: Navigate through folders with breadcrumb navigation
  • 📤 File Upload: Drag-and-drop file uploads with progress indication
  • 🎯 File Selection: Easy file picker component for forms
  • 📁 Folder Management: Create, rename, and delete folders
  • 🔄 File Operations: Rename and delete files
  • 🎨 FluxUI Integration: Beautiful, responsive UI components
  • 🌓 Dark Mode: Automatic light/dark mode compatibility
  • 🏗️ Multi-tenancy: Built-in tenant isolation support
  • 📱 Responsive: Mobile-friendly design
  • 🔒 Validation: Comprehensive file type and size validation

Requirements

  • PHP 8.4 or higher
  • Laravel 11.x
  • Livewire Flux 2.2.3+
  • Livewire Flux Pro 2.2.3+

Installation

You can install the package via composer:

composer require idkwhoami/flux-files

Run the installation command to publish the necessary files:

php artisan flux-files:install

This command will:

  • Publish the configuration file
  • Publish the database migrations
  • Publish the models to your app
  • Publish language files

Run the migrations:

php artisan migrate

Configuration

The configuration file is published to config/flux-files.php. Here are the main configuration options:

<?php

return [
    /*
    |--------------------------------------------------------------------------
    | Default Storage Disk
    |--------------------------------------------------------------------------
    |
    | The default disk to use for file storage.
    |
    */
    'disk' => env('FLUX_FILES_DISK', 'local'),

    /*
    |--------------------------------------------------------------------------
    | File Validation
    |--------------------------------------------------------------------------
    |
    | Configure file upload restrictions and validation rules.
    |
    */
    'validation' => [
        'max_file_size' => env('FLUX_FILES_MAX_SIZE', 10240), // KB
        'allowed_extensions' => [
            'images' => ['jpg', 'jpeg', 'png', 'gif', 'webp', 'svg'],
            'documents' => ['pdf', 'doc', 'docx', 'xls', 'xlsx', 'ppt', 'pptx'],
            'archives' => ['zip', 'rar', '7z', 'tar', 'gz'],
            'audio' => ['mp3', 'wav', 'ogg', 'flac'],
            'video' => ['mp4', 'avi', 'mov', 'wmv', 'flv'],
        ],
        'mime_types' => [
            // Auto-generated based on extensions
        ],
    ],

    /*
    |--------------------------------------------------------------------------
    | Eloquent Configuration
    |--------------------------------------------------------------------------
    |
    | Configure the ID type for models (bigint, uuid, ulid).
    |
    */
    'eloquent' => [
        'id_type' => env('FLUX_FILES_ID_TYPE', 'bigint'),
    ],

    /*
    |--------------------------------------------------------------------------
    | Multi-tenancy
    |--------------------------------------------------------------------------
    |
    | Enable multi-tenant support for file isolation.
    |
    */
    'multi_tenant' => [
        'enabled' => env('FLUX_FILES_MULTI_TENANT', false),
        'tenant_model' => null, // Your tenant model class
        'tenant_key' => 'tenant_id',
    ],
];

Usage

File Browser Component

The file browser component provides a complete file management interface:

<livewire:flux-files.browser 
    :current-folder-id="null"
    view-mode="grid"
    :selectable="false" />

Properties:

  • current-folder-id: ID of the folder to display (null for root)
  • view-mode: Display mode ('grid' or 'table')
  • selectable: Whether files can be selected

Events:

  • file-selected: Fired when a file is selected
  • folder-changed: Fired when navigating to a different folder

File Selection Component

Use this component to add file selection to forms:

<livewire:flux-files.select 
    name="avatar"
    :selected-file-id="$user->avatar_id"
    placeholder="Select an image..."
    :required="true" />

Properties:

  • name: Form field name
  • selected-file-id: ID of the currently selected file
  • placeholder: Placeholder text
  • required: Whether selection is required

File Upload Component

For drag-and-drop file uploads:

<livewire:flux-files.upload 
    :target-folder-id="$folderId"
    :allowed-types="['images', 'documents']"
    :max-files="5" />

Properties:

  • target-folder-id: ID of the folder to upload to
  • allowed-types: Array of allowed file type categories
  • max-files: Maximum number of files to upload

Blade Components

The package provides numerous Blade components for custom implementations:

File Display Components

<x-flux-files:file-icon :file="$file" />
<x-flux-files:folder-icon :folder="$folder" />
<x-flux-files:file-item-grid :file="$file" />
<x-flux-files:file-item-table :file="$file" />
<x-flux-files:file-preview :file="$file" />
<x-flux-files:file-size :file="$file" />
<x-flux-files:file-date :file="$file" />

Navigation Components

<x-flux-files:breadcrumbs :current-folder="$folder" />
<x-flux-files:view-mode-toggle />
<x-flux-files:sort-controls />

Upload Components

<x-flux-files:drop-zone />
<x-flux-files:upload-progress :files="$files" />
<x-flux-files:file-upload-item :file="$file" />

Models

The package includes two main models:

File Model

use App\Models\File;

// Get file URL
$url = $file->getUrl();

// Get preview URL (for images)
$previewUrl = $file->getPreviewUrl();

// Check file type
$isImage = $file->isImage();
$isAudio = $file->isAudio();
$isVideo = $file->isVideo();

// Get human-readable size
$size = $file->getHumanReadableSize();

// Relationships
$folder = $file->folder;
$tenant = $file->tenant; // if multi-tenancy enabled

// Scopes
$files = File::byTenant($tenantId)->get();
$images = File::byMimeType('image')->get();
$folderFiles = File::inFolder($folderId)->get();

Folder Model

use App\Models\Folder;

// Get full folder path
$path = $folder->getFullPath();

// Check if folder is ancestor of another
$isAncestor = $folder->isAncestorOf($otherFolder);

// Get all descendants
$descendants = $folder->getDescendants();

// Create subfolder
$subfolder = $folder->createSubfolder('New Folder');

// Relationships
$files = $folder->files;
$children = $folder->children;
$parent = $folder->parent;

// Scopes
$rootFolders = Folder::roots()->get();
$tenantFolders = Folder::byTenant($tenantId)->get();

Services

FileStorageService

use Idkwhoami\FluxFiles\Services\FileStorageService;

$storage = app(FileStorageService::class);

// Store file
$file = $storage->store($uploadedFile, $folderId);

// Delete file
$storage->delete($file);

// Move file
$storage->move($file, $newFolderId);

// Copy file
$newFile = $storage->copy($file, $targetFolderId);

// Check if file exists
$exists = $storage->exists($file);

FileValidationService

use Idkwhoami\FluxFiles\Services\FileValidationService;

$validator = app(FileValidationService::class);

// Validate file
$isValid = $validator->validateFile($uploadedFile);

// Validate file type
$isValidType = $validator->validateFileType($uploadedFile, ['images']);

// Validate file size
$isValidSize = $validator->validateFileSize($uploadedFile);

// Get validation errors
$errors = $validator->getErrors();

Advanced Usage

Multi-tenancy

Enable multi-tenancy in your configuration:

'multi_tenant' => [
    'enabled' => true,
    'tenant_model' => App\Models\Tenant::class,
    'tenant_key' => 'tenant_id',
],

Then use the tenant scope in your queries:

// Get files for current tenant
$files = File::byTenant(auth()->user()->tenant_id)->get();

// Get folders for current tenant
$folders = Folder::byTenant(auth()->user()->tenant_id)->get();

Custom File Types

Add custom file type validation:

// In your service provider
use Idkwhoami\FluxFiles\Services\FileValidationService;

FileValidationService::addCustomType('custom', [
    'extensions' => ['custom', 'ext'],
    'mime_types' => ['application/custom'],
    'max_size' => 5120, // KB
]);

Events

Listen for file events:

use Idkwhoami\FluxFiles\Events\FileUploaded;
use Idkwhoami\FluxFiles\Events\FileDeleted;

// In your EventServiceProvider
protected $listen = [
    FileUploaded::class => [
        // Your listeners
    ],
    FileDeleted::class => [
        // Your listeners
    ],
];

Custom Views

Publish and customize the views:

php artisan vendor:publish --tag=flux-files-views

Views will be published to resources/views/vendor/flux-files/.

Commands

The package includes helpful Artisan commands:

Install Command

php artisan flux-files:install

Publishes all necessary files and sets up the package.

Publishing Individual Assets

# Publish configuration
php artisan vendor:publish --tag=flux-files-config

# Publish migrations
php artisan vendor:publish --tag=flux-files-migrations

# Publish models
php artisan vendor:publish --tag=flux-files-models

# Publish views
php artisan vendor:publish --tag=flux-files-views

# Publish language files
php artisan vendor:publish --tag=flux-files-lang

# Publish everything
php artisan vendor:publish --tag=flux-files

Testing

Run the package tests:

composer test

Run code analysis:

composer analyse

Format code:

composer pint

Contributing

Please see CONTRIBUTING.md for details on how to contribute to this project.

Security

If you discover any security-related issues, please email the maintainer instead of using the issue tracker.

Credits

License

The MIT License (MIT). Please see License File for more information.

Changelog

Please see CHANGELOG.md for recent changes.

Flux Files - Making file management in Laravel applications elegant and effortless.

idkwhoami/flux-files 适用场景与选型建议

idkwhoami/flux-files 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 4 次下载、GitHub Stars 达 0, 最近一次更新时间为 2025 年 07 月 22 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「laravel」 「Idkwhoami」 「flux-files」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 idkwhoami/flux-files 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 idkwhoami/flux-files 我们能提供哪些服务?
定制开发 / 二次开发

基于 idkwhoami/flux-files 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2025-07-22