- AmazonS3 & AclAwareAmazonS3
- Apc
- AwsS3
- AzureBlobStorage
- Cache
- Doctrine DBAL: TBW
- Dropbox: TBW
- Ftp
- Google Cloud Storage
- GridFS
- InMemory
- Local & SafeLocal
- MogileFS: TBW
- OpenCloud & LazyOpenCloud
- PhpseclibSftp
- Sftp
- Zip
If you have to deal with a slow filesystem, it is out of question to use it directly. So, you need a cache! Happily, Gaufrette offers a cache system ready for use. It consist of an adapter decorator itself composed of two adapters:
* The *source* adapter that should be cached
* The *cache* adapter that is used to cache
Here is an example of how to cache an ftp filesystem:
<?php
use Gaufrette\Filesystem;
use Gaufrette\Adapter\Ftp as FtpAdapter;
use Gaufrette\Adapter\Local as LocalAdapter;
use Gaufrette\Adapter\Cache as CacheAdapter;
// Locale Cache-Directory (e.g. '%kernel.root_dir%/cache/%kernel.environment%/filesystem') with create = true
$local = new LocalAdapter($cacheDirectory, true);
// FTP Adapter with a defined root-path
$ftp = new FtpAdapter($path, $host, $username, $password, $port);
// Cached Adapter with 3600 seconds time to live
$cachedFtp = new CacheAdapter($ftp, $local, 3600);
$filesystem = new Filesystem($cachedFtp);
The third parameter of the cache adapter is the time to live of the cache.
Sometimes, you don't have the choice, you must get a streamable file URL (i.e to use native file functions). Let's take a look at the following example:
$adapter = new InMemoryAdapter(array('hello.txt' => 'Hello World!'));
$filesystem = new Filesystem($adapter);
$map = StreamWrapper::getFilesystemMap();
$map->set('foo', $filesystem);
StreamWrapper::register();
copy('gaufrette://foo/hello.txt', 'gaufrette://foo/world.txt');
unlink('gaufrette://foo/hello.txt');
echo file_get_contents('gaufrette://foo/world.txt'); // Says "Hello World!"