kitpages/file-system-bundle
Composer 安装命令:
composer require kitpages/file-system-bundle
包简介
Symfony Kitpages FileSystem Bundle. Abstraction layer for files (local, S3)
README 文档
README
This is a Symfony2 bundle that provides a filesystem abstraction layer. Basicaly this does the same as the gaufrette library from KnpLabs, but it manages much more efficiently big files. We can manage a 2GB file with a memory limit of 128Mo for the PHP process. We never transfert the entire content in a $content variable.
With this bundle you can save your files on different filesystems (S3, Local filesystem, FTP,...)
Some elements of the configuration system are based on the code of the KnpGaufretteBundle.
Versions
2019-01-23 : v4.0.0
- [new] upgrade to Symfony 2.8, 3.x, 4.x
- [doc] best doc for tests
2018-05-16 : v3.2.1
- [fix] url of the file in the flysystem system for swift
- [fix] fix pb when the file doesn't exist in flysystem adapter
- [fix] fix mime type problem in flysystem adapter
2018-05-15 : v3.2.0
- [new] integration with flysystem
Lot of doc is missing here...
2012-05-24 : v1.0.0
- first stable release
Actual state
This bundle is stable. The adapters are :
- Local adapter : file system of the server
- S3 adapter : for Amazon Web Service AWS S3
- FTP adapter : for FTP access
- FlySystem adapater : for a link to flysystem
Installation
You need to add the following lines in your deps :
Using Composer, just $ composer require kitpages/file-system-bundle package or:
{ "require": { "kitpages/file-system-bundle": "dev-master" } }
Only if you use AmazonS3
{ "require": { amazonwebservices/aws-sdk-for-php: ~1.5 } }
Only if you use Flysystem
{ "require": { "league/flysystem": "^1.0", "oneup/flysystem-bundle": "^1.14", } }
AppKernel.php
$bundles = array( ... new Kitpages\FileSystemBundle\KitpagesFileSystemBundle(), );
// AWS SDK needs a special autoloader
require_once __DIR__.'/../vendor/aws-sdk/sdk.class.php';
Configuration example
The following configuration defines 3 filesystems :
- kitpagesFile : a local filesystem
- kitpagesAmazon : a filesystem on Amazon S3
- kitpagesFlysystem : another filesystem abstraction
Let's see the configuration in config.yml
kitpages_file_system: file_system_list: kitpagesFile: local: directory_public: %kernel.root_dir%/../web directory_private: %kernel.root_dir% base_url: %base_url% kitpagesAmazon: amazon_s3: bucket_name: %kitpagesFile_amazons3_bucketname% key: %kitpagesFile_amazons3_key% secret_key: %kitpagesFile_amazons3_secretkey% kitpagesFlysystem: flysystem: flysystem_adapter: oneup_flysystem.your_filesystem file_uri_prefix: https://your.custom.url/4687311687643/FRA/
Usage example
// use AdapterFile at the beginning of the file use Kitpages\FileSystemBundle\Model\AdapterFile; // get the adapter $localAdapter = $this->get("kitpages_file_system.file_system.kitpagesFile"); $s3Adapter = $this->get("kitpages_file_system.file_system.kitpagesAmazon"); // private files (without direct public URL) $adapter->copyTempToAdapter("/my_physical_dir/foo.txt", new AdapterFile("bar/foo.txt") ); $adapter->copyAdapterToTemp(new AdapterFile("bar/foo.txt"), "/my_physical_dir/foo.txt" ); // public files (with a direct URL given by the adapter) $adapter->copyTempToAdapter("/my_physical_dir/foo.txt", new AdapterFile("bar/foo.txt", true) ); $url = $adapter->getFileLocation(new AdapterFile("bar/foo.txt", true)); // some functions of the adapter : $adapterFile = new AdapterFile("bar/foo.txt"); $adapter->copyTempToAdapter("/my_physical_dir/foo.txt", $adapterFile ); $content = $adapter->getFileContent($adapterFile); $adapter->sendFileToBrowser($adapterFile); if ($adapter->isFile($adapterFile) ) { // if file exists in the adapter }
Run the tests
cd Tests/app/web
php -S localhost:8888
kitpages/file-system-bundle 适用场景与选型建议
kitpages/file-system-bundle 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 45.59k 次下载、GitHub Stars 达 12, 最近一次更新时间为 2012 年 05 月 24 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「filesystem」 「File abstraction layer」 「gaufrette」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 kitpages/file-system-bundle 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 kitpages/file-system-bundle 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 kitpages/file-system-bundle 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
A SDK for working with B2 cloud storage.
A PHP class providing static methods for reading, writing, copying, moving, and deleting files and directories, MIME type detection, image size detection, and file permission management
The file manager intended for using Laravel with CKEditor / TinyMCE / Colorbox
Powerful PHP database abstraction layer (DBAL) with many features for database schema introspection and management.
ADOdb is a PHP database abstraction layer library
The flysystem adapter for yandex disk rest api.
统计信息
- 总下载量: 45.59k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 12
- 点击次数: 8
- 依赖项目数: 4
- 推荐数: 0
其他信息
- 授权协议: BSD
- 更新时间: 2012-05-24