gfrances/as3streamwrapper
Composer 安装命令:
composer require gfrances/as3streamwrapper
包简介
Symfony2 port of the P'unk Avenue as3streamwrapper (https://github.com/punkave/aS3StreamWrapper)
README 文档
README
aS3StreamWrapper: a better Amazon S3 stream wrapper for PHP
ABOUT
This is an Amazon S3 stream wrapper. It lets your PHP code use
fopen(), file_put_contents(), opendir(), readdir(), closedir(),
stat(), copy() and friends via Amazon S3. Unlike most wrappers there
is full support for subdirectories (not just directory listings of
entire buckets).
LIMITATIONS
Be aware that files are buffered entirely in memory which will lead to
out of memory errors on files larger than your PHP memory limit.
For our use cases this currently makes a lot of sense, but
perhaps we'll add support for buffering on the local drive instead
as an option specified when registering a protocol or creating
a stream context. It's not hard compared to the stuff we've
covered already.
UNUSUAL FEATURES
* You can make subdirectories and sub-subdirectories (most S3
wrappers don't support S3's native features for listing things
with a prefix and a limit)
* You can register the wrapper more than once under different names
* You can subclass and extend the wrapper class properly
* Caching support for fast read access to the first 8K of each file
* Extensive unit tests
USAGE
Registering the stream wrapper is easy:
$wrapper = new aS3StreamWrapper();
$wrapper->register(array('protocol' => 's3',
'acl' => AmazonS3::ACL_PUBLIC,
'key' => 'your key id',
'secretKey' => 'your secret key',
'region' => AmazonS3::REGION_US_W1));
Now you can open files over S3 with, for instance:
fopen("s3://bucketname/subdir/filename.txt", "w");
Note that the first directory level is the bucket name.
You must use mkdir() to create a new bucket. Calling
mkdir() and rmdir() for subdirectories belong the bucket
level is not really necessary but we support it so that
your code works naturally.
See lib/wrapper/aS3StreamWrapperTest.php for extensive examples
of proper usage.
Note that you can register *more than one* protocol name,
with *different* options. Which means that you can copy
files from region to region or with different ACL settings
(public vs. private).
Many (but not all) PHP functions accept stream wrapper URLs.
See:
http://php.net/manual/en/book.stream.php
For the official PHP documentation on this. There are
many
Our stream wrapper class is in lib/wrapper along with
its tests. lib/vendor contains a recent snapshot of the
official AWS PHP SDK from Amazon.
CACHING
S3 is great at delivering content to end users
and scaling the storage of content in general, but you don't want to do
many reads of entire S3 objects in rapid succession just to peek at
their headers to determine image dimensions, file type, etc. The
optional cache feature addresses this problem. You supply the cache
object.
In addition to the options demonstrated above and in the tests,
you can specify a 'cache' option, which must point to a cache object
that supports get($key), set($key, $data, $timeout-in-seconds),
has($key) and remove($key) methods (hint: any subclass of sfCache is
cool). This cache is used to store the first 8K of every file and also
the results of stat().
Consider using memcache or even a MySQL cache that is fast and local
to your servers. Of course, all of your servers must use the cache
consistently to get consistent results.
SYMFONY
Although we built this for Symfony and Apostrophe, the wrapper has
no dependencies on Symfony or Apostrophe. But if you add this
folder to your plugins/ folder in a Symfony 1.x project and
add it to ProjectConfiguration in the usual way, you'll be able
to autoload the stream wrapper. Just FYI.
WARNING
Use at your own risk. There is no warranty, express or implied.
LICENSE
Copyright 2011 P'unk Avenue LLC. Released under the BSD license.
Built for Apostrophe: apostrophenow.com
CONTACT
Questions? Contact us via http://github.com/punkave
Also follow us at http://punkave.com/ and @punkave
gfrances/as3streamwrapper 适用场景与选型建议
gfrances/as3streamwrapper 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 1.05k 次下载、GitHub Stars 达 2, 最近一次更新时间为 2012 年 11 月 19 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「s3」 「aws」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 gfrances/as3streamwrapper 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 gfrances/as3streamwrapper 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 gfrances/as3streamwrapper 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
This package includes a script and fail2ban configuration that allows you to use fail2ban when utilizing AWS elastic load balancer (ELB) and an apache webserver.
Elastic Driver for Laravel Scout
simple api library.
A replica of the AWS Elastic Beanstalk worker SQS daemon (sqsd) in PHP
A beautiful, zero-dependency UI for querying and viewing AWS CloudWatch logs directly inside your Laravel application.
A simple Laravel 5/6/7/8 service provider for including the AWS SDK for PHP.
统计信息
- 总下载量: 1.05k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 2
- 点击次数: 18
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: Unknown
- 更新时间: 2012-11-19