定制 codprez/laravel-media-library 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

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

codprez/laravel-media-library

Composer 安装命令:

composer require codprez/laravel-media-library

包简介

Media library with upload, variants, and selector UI for Laravel + Inertia + React.

README 文档

README

A robust media library management system for Laravel applications using Inertia.js and React. It provides a full-featured media manager with upload capabilities, variants (thumbnails), and a selector UI.

Features

  • Media Management: Upload, rename, and delete media files.
  • Bulk Uploads: Upload multiple files in a single request.
  • Variant Generation: Automatic generation of thumbnails and webp variants (expandable).
  • Inertia/React Integration: Ready-to-use components for selecting and managing media in your admin panel.
  • Filtering: Filter media by type (image, video, document) and search by name.
  • Multi-delete: Select and remove multiple files at once.
  • Google Drive Import (Public Links): Paste a public file/folder link, preview files, select some or all, and import in the background.

Requirements

  • PHP 8.2+
  • Laravel 12.x | 13.x
  • Inertia.js (React)

Installation

You can install the package via composer:

composer require codprez/laravel-media-library

Publish Configuration and Migrations

php artisan vendor:publish --tag="media-library-config"
php artisan vendor:publish --tag="media-library-migrations"

Run Migrations

php artisan migrate

Configuration

The configuration file is located at config/media-library.php. Here you can define the user model for relationships:

return [
    'user_model' => \App\Models\User::class,
    'disk' => 'public',
    'google_drive' => [
        'api_key' => env('GOOGLE_DRIVE_API_KEY'),
    ],
];

Google Drive Import Setup

To import public Google Drive folders, set an API key:

GOOGLE_DRIVE_API_KEY=your_google_api_key

Then run migrations so import tracking columns/tables exist:

php artisan migrate

Usage

Backend

The package provides a Media model and a MediaController. By default, it uses the public disk for storage.

Handling Uploads

The MediaController includes a store method that handles file uploads and automatically generates metadata.

// In your routes/web.php or routes/api.php
use Codprez\MediaLibrary\Http\Controllers\MediaController;

Route::post('/admin/media', [MediaController::class, 'store'])->name('admin.media.store');

Frontend (Inertia + React)

The package includes React components located in resources/js. You can import and use them in your Inertia pages.

Component Example

import { MediaSelector } from 'codprez/laravel-media-library';

function MyForm() {
    return (
        <MediaSelector 
            onSelect={(media) => console.log(media)}
            multiple={false}
        />
    );
}

License

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

codprez/laravel-media-library 适用场景与选型建议

codprez/laravel-media-library 是一款 基于 TypeScript 开发的 Composer 扩展包,目前已累计 258 次下载、GitHub Stars 达 1, 最近一次更新时间为 2026 年 04 月 13 日, 在 PHP 生态内属于活跃度较高的组件。

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

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

围绕 codprez/laravel-media-library 我们能提供哪些服务?
定制开发 / 二次开发

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

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

GitHub 信息

  • Stars: 1
  • Watchers: 0
  • Forks: 0
  • 开发语言: TypeScript

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-04-13