PHPackages                             gfrances/as3streamwrapper - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [File &amp; Storage](/categories/file-storage)
4. /
5. gfrances/as3streamwrapper

ActiveLibrary[File &amp; Storage](/categories/file-storage)

gfrances/as3streamwrapper
=========================

Symfony2 port of the P'unk Avenue as3streamwrapper (https://github.com/punkave/aS3StreamWrapper)

21.0kPHP

Since Nov 19Pushed 13y ago1 watchersCompare

[ Source](https://github.com/gfrances/aS3StreamWrapper)[ Packagist](https://packagist.org/packages/gfrances/as3streamwrapper)[ RSS](/packages/gfrances-as3streamwrapper/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependenciesVersions (1)Used By (0)

```
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
```

###  Health Score

24

—

LowBetter than 32% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity17

Limited adoption so far

Community12

Small or concentrated contributor base

Maturity41

Maturing project, gaining track record

 Bus Factor2

2 contributors hold 50%+ of commits

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

### Community

Maintainers

![](https://www.gravatar.com/avatar/78cb93cefe8309b14b0302f7959a3a05887981ee366155a42279861d48c22e2e?d=identicon)[gfrances](/maintainers/gfrances)

---

Top Contributors

[![gfrances](https://avatars.githubusercontent.com/u/1112014?v=4)](https://github.com/gfrances "gfrances (5 commits)")[![opengeek](https://avatars.githubusercontent.com/u/232812?v=4)](https://github.com/opengeek "opengeek (3 commits)")[![iknowfoobar](https://avatars.githubusercontent.com/u/255807?v=4)](https://github.com/iknowfoobar "iknowfoobar (1 commits)")[![MDrollette](https://avatars.githubusercontent.com/u/329784?v=4)](https://github.com/MDrollette "MDrollette (1 commits)")[![phpdiddy](https://avatars.githubusercontent.com/u/226604?v=4)](https://github.com/phpdiddy "phpdiddy (1 commits)")

### Embed Badge

![Health badge](/badges/gfrances-as3streamwrapper/health.svg)

```
[![Health](https://phpackages.com/badges/gfrances-as3streamwrapper/health.svg)](https://phpackages.com/packages/gfrances-as3streamwrapper)
```

###  Alternatives

[knplabs/gaufrette

PHP library that provides a filesystem abstraction layer

2.5k39.8M123](/packages/knplabs-gaufrette)[google/cloud-storage

Cloud Storage Client for PHP

34390.8M125](/packages/google-cloud-storage)[illuminate/filesystem

The Illuminate Filesystem package.

15261.6M2.6k](/packages/illuminate-filesystem)[superbalist/flysystem-google-storage

Flysystem adapter for Google Cloud Storage

26320.6M30](/packages/superbalist-flysystem-google-storage)[creocoder/yii2-flysystem

The flysystem extension for the Yii framework

2931.7M62](/packages/creocoder-yii2-flysystem)[flowjs/flow-php-server

PHP library for handling chunk uploads. Works with flow.js html5 file uploads.

2451.6M15](/packages/flowjs-flow-php-server)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
