maniaba/asset-connect
Composer 安装命令:
composer require maniaba/asset-connect
包简介
AssetConnect is a file management library for CodeIgniter 4 that allows you to associate files with any entity in your application
关键字:
README 文档
README
AssetConnect is a file management library for CodeIgniter 4 that allows you to associate files with any entity in your application. It provides a robust, flexible solution for handling file uploads, storage, retrieval, variants, public custom metadata, backend-only internal metadata, and secure access control.
Storage is backed by named Flysystem disks. Asset records store the disk name and relative storage path, not absolute filesystem paths, so moving the application directory does not invalidate stored assets.
Features
- Associate files with any CodeIgniter entity
- Organize files into typed asset collections
- Store files on named Flysystem disks, including local, S3-compatible, FTP, SFTP, Google Cloud Storage, Azure Blob Storage, WebDAV, memory, or custom adapters
- Generate public URLs from disk
public_urlconfiguration or serve protected assets through AssetConnect routes - Generate variants inline or through CodeIgniter Queue
- Move existing assets between storage disks with
Asset::transferToStorage() - Process remote files through
copyToTemporaryFile()andwithTemporaryFile()whenlocal_pathis not available - Keep public custom properties separate from backend-only internal properties
- Use pending assets for multi-step upload confirmation flows
Requirements
- PHP 8.3 or higher
- CodeIgniter 4.6 or higher
- CodeIgniter Queue
- Flysystem 3
Installation
Install the package:
composer require maniaba/asset-connect
Run the package migrations:
php spark migrate --namespace=Maniaba\\AssetConnect
If you use the default local public disk, expose it from public/:
php spark asset-connect:storage-link
Example Usage
// Add an asset to a user $asset = $user->addAsset('/path/to/file.jpg') ->withCustomProperties([ 'title' => 'Profile Picture', 'description' => 'User profile picture' ]) ->toAssetCollection(ImagesCollection::class); // Get all assets for a user $assets = $user->getAssets(); // Get assets from a specific collection $images = $user->getAssets(ImagesCollection::class); // Get the URL to an asset $url = $user->getFirstAsset(ImagesCollection::class)->getUrl(); // Delete assets from a specific collection $user->deleteAssets(ImagesCollection::class);
Storage Quick Start
AssetConnect stores only storage and a storage-relative path in the database. Configure physical roots, visibility, and public URL prefixes in Config\Asset:
public string $defaultPublicStorage = 'public'; public string $defaultProtectedStorage = 'protected'; public array $storages = [ 'public' => [ 'driver' => 'local', 'root' => WRITEPATH . 'asset-connect/public', 'public_url' => 'assets/storage', 'visibility' => 'public', ], 'protected' => [ 'driver' => 'local', 'root' => WRITEPATH . 'asset-connect/protected', 'visibility' => 'protected', ], ];
Remote disks can be added through Flysystem adapters and storage-specific setup methods such as setupStorageS3(). Legacy driver-specific setup methods such as setupStorageAwsS3() are still supported as a fallback. Public remote disks should define an HTTP public_url; protected disks are served through AssetConnect routes and authorization.
For remote disks, local_path can be null. Use temporary-file helpers for processors that require a local filesystem path:
$asset->withTemporaryFile(static function (string $source): void { service('image') ->withFile($source) ->resize(1200, 900, true) ->save(WRITEPATH . 'cache/processed.jpg'); });
Move an existing asset and its variants to another configured disk:
$asset->transferToStorage('protected'); $asset->transferToStorage('s3_public', deleteSource: false);
Upgrade Guides
Version 2.1.0 resolves custom storage setup methods from the configured storage disk name first, with a legacy driver-based fallback.
Read the full guide when upgrading from 2.0.0: Upgrade from 2.0.0 to 2.1.0.
Version 2.0.0 changes storage from filesystem-root paths to named storage disks.
Read the full guide before migrating production data: Upgrade from 1.0.2 to 2.0.0.
Documentation
Comprehensive documentation is available at https://maniaba.github.io/asset-connect/.
Versioned documentation is published with mike. The Docs workflow validates docs on pull requests, publishes every push to develop as the develop docs version, and publishes release documentation from release tags such as v2.1.0. Stable releases move the latest alias and default redirect to the released docs version.
For local checks and manual publishing:
pip install -r docs/requirements.txt mkdocs build --strict mike deploy --push develop mike deploy --push --update-aliases 2.1.0 latest mike set-default --push latest
Find yourself stuck using the package? Found a bug? Do you have general questions or suggestions for improving the media library? Feel free to create an issue on GitHub, we'll try to address it as soon as possible.
Testing
Run the test suite with:
composer test
For more detailed testing options:
# Run with code coverage composer test -- --coverage-html=build/coverage # Run static analysis composer analyze
Changelog
All notable changes to this project are documented in the CHANGELOG.md file.
Contributing
Contributions are welcome! Please see CONTRIBUTING.md for details on how to contribute to this project.
Security
If you discover a security vulnerability, please send an email to maniaba@outlook.com instead of using the issue tracker. All security vulnerabilities will be promptly addressed.
License
The MIT License (MIT). Please see License File for more information.
maniaba/asset-connect 适用场景与选型建议
maniaba/asset-connect 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 15.47k 次下载、GitHub Stars 达 10, 最近一次更新时间为 2025 年 07 月 05 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「codeigniter」 「files」 「file-upload」 「asset-management」 「codeigniter4」 「php83」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 maniaba/asset-connect 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 maniaba/asset-connect 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 maniaba/asset-connect 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
An HTML5 upload field for the CMS and frontend forms.
The CodeIgniter Redis package
A very simple yet useful helper class to handle PHP file uploads.
The flysystem adapter for yandex disk rest api.
Integrates the rekalogika/file library into the Symfony framework.
Upload files using Symfony Form, FilePond, and the rekalogika/file framework
统计信息
- 总下载量: 15.47k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 10
- 点击次数: 26
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2025-07-05