vdauchy/eloquent-flysystem-adaptor
Composer 安装命令:
composer require vdauchy/eloquent-flysystem-adaptor
包简介
README 文档
README
Introduction
This package is an Adaptor for Flysystem using Laravel's ORM (Eloquent).
In config\filesystems.php add your new disk as:
return [ 'disks' => [ /* Name your disk as you wish */ 'my_sql_disk' => [ /* Use 'eloquent' driver that is registered by this package. */ 'driver' => 'eloquent', /* Optional: Set your custom model that extends the base Model to use different tables per disk */ 'model' => CustomContentModel::class, /* Optional: Set a custom callable to generate urls or just overwrite the static method 'getUrl()' */ 'getUrl' => [CustomContentModel::class, 'getSomeCustomUrl'] ] ] ];
Create as many models as you wish like:
use VDauchy\EloquentFlysystemAdaptor\models\Content; class CustomContentModel extends Content { /** * Example of `getUrl` overwrite to generate URLs using the UUID. */ static public function getUrl(string $path, ?array $metadata): string { return route('my.custom.content', ['uuid' => $metadata['uuid']]); } }
Create controllers like:
Route::get('my-custom-content/{uuid}', function (string $uuid) { $content = CustomContentModel::fromUuid($uuid); /* TODO: Add checks for public/private visibility and improve type/mime handling */ return response($content->contents, 200, ['Content-Type' => $content->mimetype]); }) ->where('uuid', '^[a-z0-9\-]{36}$') ->name('my.custom.content');
Maintenance
Here are the steps to develop/test this package using docker:
# Make sure no image with the same tag exists. docker image rm php-cli-eloquent-flysystem-adaptor:latest -f; # Build new image with the expected extensions. docker build . -t php-cli-eloquent-flysystem-adaptor:latest; # Update vendors. docker run \ --volume $(pwd):/usr/src/app \ php-cli-eloquent-flysystem-adaptor:latest \ composer update; # Run unit tests. docker run \ --volume $(pwd):/usr/src/app \ php-cli-eloquent-flysystem-adaptor:latest \ composer unit; # Run static analysis. docker run \ --volume $(pwd):/usr/src/app \ php-cli-eloquent-flysystem-adaptor:latest \ composer lint; # Run style check. docker run \ --volume $(pwd):/usr/src/app \ php-cli-eloquent-flysystem-adaptor:latest \ composer fmt;
License
The MIT License (MIT). Please see License File for more information.
vdauchy/eloquent-flysystem-adaptor 适用场景与选型建议
vdauchy/eloquent-flysystem-adaptor 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 23 次下载、GitHub Stars 达 2, 最近一次更新时间为 2021 年 02 月 22 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 vdauchy/eloquent-flysystem-adaptor 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 vdauchy/eloquent-flysystem-adaptor 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 23
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 2
- 点击次数: 7
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2021-02-22