41 Commits

Author SHA1 Message Date
Leszek Prabucki
f330085843 Merge pull request #80 from shieldo/patch-1
use stable releases of gaufrette (~0.1.7)
2014-03-24 23:15:03 +01:00
Douglas Greenshields
886fdf6ad3 use stable releases of gaufrette (~0.1.7) 2014-03-09 02:20:29 +00:00
Leszek Prabucki
171844b400 Merge pull request #69 from Gesthispania/master
Add FTP SSL/TSL Option
2013-12-30 00:59:49 -08:00
Leszek Prabucki
212c2db832 Merge pull request #53 from nmpolo/master
Allow AclAwareAmazonS3Adapter to have options set
2013-12-30 00:55:42 -08:00
Leszek Prabucki
3bf4e03513 Merge pull request #76 from teohhanhui/master
AwsS3 adapter: added ACL option in configuration
2013-11-12 23:41:39 -08:00
Teoh Han Hui
96061210e4 AwsS3 adapter: added ACL option in configuration 2013-11-13 02:14:41 +08:00
Leszek Prabucki
7c210044bf Merge pull request #73 from krafas/master
Allow AmazonsS3 adapter to have acl option
2013-11-10 01:08:40 -08:00
Leszek Prabucki
9e70925730 Merge pull request #67 from radutopala/master
Dropbox Adapter Factory added
2013-11-04 00:31:06 -08:00
Giedrius Sabaliauskas
b5c3b03285 Allow AmazonsS3 adapter to gave acl option 2013-10-29 18:01:53 +02:00
Gesthispania
8b143c5065 Update FtpAdapterFactory.php 2013-10-10 10:19:27 +02:00
Gesthispania
ef1f8a75ac Add SSL option to work with modified Gaufrette that use SSL/TSL FTP 2013-10-10 09:58:17 +02:00
Leszek Prabucki
c01f131f7c Merge pull request #68 from havvg/master
add example service for Aws\S3\S3Client
2013-10-07 06:36:41 -07:00
Radu Topala
209928f896 Update DropboxAdapterFactory.php 2013-10-06 09:25:51 +03:00
Toni Uebernickel
50ecc39137 add example service for Aws\S3\S3Client 2013-10-04 10:52:28 +02:00
Radu Topala
8875fccb5e Update README.markdown 2013-10-04 10:41:20 +03:00
Radu Topala
a4a06af459 Merge branch 'master' of github.com:radutopala/KnpGaufretteBundle 2013-10-04 06:23:40 +00:00
Radu Topala
ae786b1faa added Dropbox Adapter Factory 2013-10-04 06:17:52 +00:00
Leszek Prabucki
90080cacdb Merge pull request #62 from havvg/feature/aws_s3-adapter
add AwsS3AdapterFactory
2013-09-27 09:23:19 -07:00
Toni Uebernickel
051ab917b9 add AwsS3 docs to README 2013-09-26 20:02:45 +02:00
Toni Uebernickel
169f466849 add AwsS3AdapterFactory 2013-09-26 19:50:50 +02:00
Leszek Prabucki
b4f15993a2 Merge pull request #59 from fadoe/patch-doctrine
Patch doctrine
2013-09-23 23:39:44 -07:00
Falk Doering
2f97c9fbff Update documentation. Add doctrine usage. 2013-09-13 13:37:36 +02:00
Falk Doering
622e52c550 Use doctrine dbal connection name, rename doctrine_dbal_id into connection_name 2013-09-13 13:34:24 +02:00
Falk Doering
336e203655 Update documentation. Change composer registerNamespaces method to addClassMap. 2013-09-13 11:56:38 +02:00
Leszek Prabucki
bd695f9194 Merge pull request #60 from lmammino/azure-blob-storage
Added support for azure blob storage
2013-08-24 03:58:34 -07:00
Luciano Mammino
ee50cd8766 Added support for azure blob storage (introduced here: https://github.com/KnpLabs/Gaufrette/pull/206) 2013-08-24 11:00:36 +02:00
Falk Doering
df1d1855a5 Update inline documentation. 2013-08-12 16:53:05 +02:00
Falk Doering
02483aca83 Add doctrine dbal adapter factory 2013-08-12 16:45:35 +02:00
Nicholas Masters
d450786a7b Allow adapter options to be passed 2013-06-23 18:43:17 +00:00
Leszek Prabucki
6c615bde72 Merge pull request #52 from caponica/master
Cleaned up README and edited for readability
2013-06-17 00:53:15 -07:00
Christian Morgan
da1b5f9750 Added documentation for amazon_s3 adapter
I've added what I understand based on getting this working today. Not sure about all the options. 

I also added a note about bucket names with dots in them - this had me stuck for a while until I found mention of it in passing in an AWS ticket https://forums.aws.amazon.com/thread.jspa?threadID=122890#jive-message-445833

If it's not a generally repeatable problem feel free to delete that line, but it certainly caused me problems!
2013-06-14 22:18:40 +02:00
Christian Morgan
744a0b63c0 Cleaned up README and edited for readability 2013-06-14 14:49:25 +02:00
Leszek Prabucki
de1ef2f9b2 Merge pull request #46 from WriteOrRead/opencloud-adapter-factory
Documentation for configuring HPCloud with OpenStack
2013-04-14 23:12:02 -07:00
Richard Shank
c9c1d0006d Add documentation for using HPCloud with OpenStack 2013-04-13 00:20:13 -07:00
Luciano Mammino
9ffa559db7 Added documentation 2013-04-12 04:07:38 +03:00
Luciano Mammino
2a3cae7156 Added OpenCloudAdapterFactory 2013-04-12 02:32:10 +02:00
Leszek Prabucki
013f50495b Merge pull request #41 from gavD/master
Bugfix: Acl Aware S3 factory could not set options
2013-03-01 05:08:05 -08:00
Gavin Davies
21841d68ee Make sure definition is set in create 2013-03-01 12:43:20 +00:00
Leszek Prabucki
79cad5c65a Merge pull request #38 from l3l0/fix/configuration-for-acl-amazon
Add configuration for AclAmazonS3.
2013-02-22 10:52:47 -08:00
l3l0
216903aa08 Add configuration for AclAmazonS3. Replaces #31 2013-02-22 17:29:35 +01:00
l3l0
c260b10a0b Use 0.2.0@dev at master branch 2013-01-30 12:47:06 +01:00
14 changed files with 688 additions and 44 deletions

View File

@@ -9,4 +9,4 @@ before_script:
- php composer.phar install --dev
script:
- phpunit --coverage-text
- php bin/phpunit --coverage-text

View File

@@ -14,13 +14,18 @@ class AclAwareAmazonS3AdapterFactory implements AdapterFactoryInterface
*/
public function create(ContainerBuilder $container, $id, array $config)
{
$container
$definition = $container
->setDefinition($id.'.delegate', new DefinitionDecorator('knp_gaufrette.adapter.amazon_s3'))
->addArgument(new Reference($config['amazon_s3_id']))
->addArgument($config['bucket_name'])
->addArgument($config['create'])
;
if (isset($config['options'])) {
$definition->addArgument($config['options']);
} elseif (isset($config['create'])) {
$definition->addArgument(array('create' => $config['create']));
}
$def = $container
->setDefinition($id, new DefinitionDecorator('knp_gaufrette.adapter.acl_aware_amazon_s3'))
->addArgument(new Reference($id.'.delegate'))
@@ -84,6 +89,15 @@ class AclAwareAmazonS3AdapterFactory implements AdapterFactoryInterface
->end()
->end()
->booleanNode('create')->defaultFalse()->end()
->arrayNode('options')
->children()
->booleanNode('create')
->defaultFalse()
->end()
->scalarNode('region')->end()
->scalarNode('directory')->end()
->end()
->end()
->end()
;
}

View File

@@ -51,6 +51,7 @@ class AmazonS3AdapterFactory implements AdapterFactoryInterface
->end()
->scalarNode('region')->end()
->scalarNode('directory')->end()
->scalarNode('acl')->end()
->end()
->end()
->end()

View File

@@ -0,0 +1,54 @@
<?php
namespace Knp\Bundle\GaufretteBundle\DependencyInjection\Factory;
use Symfony\Component\Config\Definition\Builder\NodeDefinition;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\DefinitionDecorator;
use Symfony\Component\DependencyInjection\Reference;
class AwsS3AdapterFactory implements AdapterFactoryInterface
{
/**
* {@inheritDoc}
*/
public function create(ContainerBuilder $container, $id, array $config)
{
$container
->setDefinition($id, new DefinitionDecorator('knp_gaufrette.adapter.aws_s3'))
->addArgument(new Reference($config['service_id']))
->addArgument($config['bucket_name'])
->addArgument($config['options'])
;
}
/**
* {@inheritDoc}
*/
public function getKey()
{
return 'aws_s3';
}
/**
* {@inheritDoc}
*/
public function addConfiguration(NodeDefinition $builder)
{
$builder
->children()
->scalarNode('service_id')->isRequired()->cannotBeEmpty()->end()
->scalarNode('bucket_name')->isRequired()->cannotBeEmpty()->end()
->arrayNode('options')
->addDefaultsIfNotSet()
->children()
->scalarNode('directory')->defaultValue('')->end()
->booleanNode('create')->defaultFalse()->end()
->scalarNode('acl')->defaultValue('private')->end()
->end()
->end()
->end()
;
}
}

View File

@@ -0,0 +1,48 @@
<?php
namespace Knp\Bundle\GaufretteBundle\DependencyInjection\Factory;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\DefinitionDecorator;
use Symfony\Component\DependencyInjection\Reference;
use Symfony\Component\Config\Definition\Builder\NodeDefinition;
class AzureBlobStorageAdapterFactory implements AdapterFactoryInterface
{
/**
* {@inheritDoc}
*/
public function create(ContainerBuilder $container, $id, array $config)
{
$definition = $container
->setDefinition($id, new DefinitionDecorator('knp_gaufrette.adapter.azure_blob_storage'))
->addArgument(new Reference($config['blob_proxy_factory_id']))
->addArgument($config['container_name'])
->addArgument($config['create_container'])
->addArgument($config['detect_content_type']);
}
/**
* {@inheritDoc}
*/
public function getKey()
{
return 'azure_blob_storage';
}
/**
* {@inheritDoc}
*/
public function addConfiguration(NodeDefinition $builder)
{
$builder
->children()
->scalarNode('blob_proxy_factory_id')->isRequired()->cannotBeEmpty()->end()
->scalarNode('container_name')->isRequired()->cannotBeEmpty()->end()
->booleanNode('create_container')->defaultValue(false)->end()
->booleanNode('detect_content_type')->defaultValue(true)->end()
->end()
;
}
}

View File

@@ -0,0 +1,61 @@
<?php
namespace Knp\Bundle\GaufretteBundle\DependencyInjection\Factory;
use Symfony\Component\Config\Definition\Builder\NodeDefinition;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\DefinitionDecorator;
use Symfony\Component\DependencyInjection\Reference;
/**
* doctrine dbal adapter factory
*
* @author Falk Doering <falk.doering@marktjagd.de>
*/
class DoctrineDbalAdapterFactory implements AdapterFactoryInterface
{
/**
* {@inheritDoc}
*/
function create(ContainerBuilder $container, $id, array $config)
{
$definition = $container
->setDefinition($id, new DefinitionDecorator('knp_gaufrette.adapter.doctrine_dbal'))
->addArgument(new Reference('doctrine.dbal.' . $config['connection_name'] . '_connection'))
->addArgument($config['table'])
;
if (isset($config['columns'])) {
$definition->addArgument($config['columns']);
}
}
/**
* {@inheritDoc}
*/
function getKey()
{
return 'doctrine_dbal';
}
/**
* {@inheritDoc}
*/
function addConfiguration(NodeDefinition $builder)
{
$builder
->children()
->scalarNode('connection_name')->isRequired()->cannotBeEmpty()->end()
->scalarNode('table')->isRequired()->cannotBeEmpty()->end()
->arrayNode('columns')
->children()
->scalarNode('key')->end()
->scalarNode('content')->end()
->scalarNode('mtime')->end()
->scalarNode('checksum')->end()
->end()
->end()
->end()
;
}
}

View File

@@ -0,0 +1,45 @@
<?php
namespace Knp\Bundle\GaufretteBundle\DependencyInjection\Factory;
use Symfony\Component\Config\Definition\Builder\NodeDefinition;
use Symfony\Component\DependencyInjection\Reference;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\DefinitionDecorator;
/**
* Dropbox Adapter Factory
*/
class DropboxAdapterFactory implements AdapterFactoryInterface
{
/**
* {@inheritDoc}
*/
function create(ContainerBuilder $container, $id, array $config)
{
$container
->setDefinition($id, new DefinitionDecorator('knp_gaufrette.adapter.dropbox'))
->addArgument(new Reference($config['api_id']))
;
}
/**
* {@inheritDoc}
*/
function getKey()
{
return 'dropbox';
}
/**
* {@inheritDoc}
*/
function addConfiguration(NodeDefinition $builder)
{
$builder
->children()
->scalarNode('api_id')->cannotBeEmpty()->end()
->end()
;
}
}

View File

@@ -47,6 +47,7 @@ class FtpAdapterFactory implements AdapterFactoryInterface
->scalarNode('password')->defaultNull()->end()
->booleanNode('passive')->defaultFalse()->end()
->booleanNode('create')->defaultFalse()->end()
->booleanNode('ssl')->defaultFalse()->end()
->scalarNode('mode')
->defaultValue(defined('FTP_ASCII') ? FTP_ASCII : null)
->beforeNormalization()

View File

@@ -0,0 +1,53 @@
<?php
namespace Knp\Bundle\GaufretteBundle\DependencyInjection\Factory;
use Symfony\Component\Config\Definition\Builder\NodeDefinition;
use Symfony\Component\DependencyInjection\Reference;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\DefinitionDecorator;
/**
* OpenCloud adapter factory
*
* @author Mammino Luciano 2013 <lmammino@oryzone.com>
*/
class OpenCloudAdapterFactory implements AdapterFactoryInterface
{
/**
* {@inheritDoc}
*/
public function create(ContainerBuilder $container, $id, array $config)
{
$container
->setDefinition($id, new DefinitionDecorator('knp_gaufrette.adapter.opencloud'))
->replaceArgument(0, new Reference($config['object_store_id']))
->replaceArgument(1, $config['container_name'])
->replaceArgument(2, $config['create_container'])
->replaceArgument(3, $config['detect_content_type'])
;
}
/**
* {@inheritDoc}
*/
public function getKey()
{
return 'opencloud';
}
/**
* {@inheritDoc}
*/
public function addConfiguration(NodeDefinition $node)
{
$node
->children()
->scalarNode('object_store_id')->isRequired()->cannotBeEmpty()->end()
->scalarNode('container_name')->isRequired()->cannotBeEmpty()->end()
->booleanNode('create_container')->defaultFalse()->end()
->booleanNode('detect_content_type')->defaultTrue()->end()
->end()
;
}
}

View File

@@ -7,7 +7,7 @@ About Gaufrette
---------------
Gaufrette is a PHP 5.3+ library providing a filesystem abstraction layer.
This abstraction layer permits you to develop your applications without the need to know where all their medias will be stored and how.
This abstraction layer allows you to develop applications without needing to know where all their media files will be stored or how.
Documentation is available the [official page of Gaufrette][gaufrette-homepage].
@@ -36,26 +36,32 @@ you must add the following lines to it:
### Composer Style
Bundle can be installed using composer by add to require `composer.json` part `"knplabs/knp-gaufrette-bundle": "dev-master"` line.
This bundle can be installed using composer by adding the following in the `require` section of your `composer.json` file:
```
"require": {
...
"knplabs/knp-gaufrette-bundle": "dev-master"
},
```
### Git Submodule Style
If you are versioning your project with git, you had better to embed it
as a submodule:
If you are versioning your project with git and making changes to this bundle you can embed it as a submodule:
$ git submodule add https://github.com/KnpLabs/KnpGaufretteBundle.git vendor/bundles/Knp/Bundle/GaufretteBundle
## Add the namespace in the autoloader
## Add the namespace in the autoloader
You must register both Gaufrette and the KnpGaufretteBundle in your autoloader:
(You do not have to do that if you are using composer autoload system.)
(You do not have to do this if you are using the composer autoload system.)
``` php
<?php
// app/autoload.php
$loader->registerNamespaces(array(
$loader->addClassMap(array(
'Knp\Bundle' => __DIR__.'/../vendor/bundles',
'Gaufrette' => __DIR__.'/../vendor/gaufrette/src',
// ...
@@ -103,7 +109,7 @@ knp_gaufrette:
directory: /path/to/my/filesystem
```
The defined adapters are usable to create the filesystems.
The defined adapters are then used to create the filesystems.
## Configuring the Filesystems
@@ -118,26 +124,26 @@ knp_gaufrette:
alias: foo_filesystem
```
Each defined filesystem must have an `adapter` with the key of an adapter as value.
The filesystem defined above with result in a service with id `gaufrette.bar_filesystem`.
The `alias` parameter permits to also defines an alias for it.
Each defined filesystem must have an `adapter` with its value set to an adapter's key.
The filesystem defined above will result in a service with id `gaufrette.bar_filesystem`.
The `alias` parameter allows us to define an alias for it (`foo_filesystem` in this case).
The filesystem map
------------------
You can access to all declared filesystems through the map service.
You can access all declared filesystems through the map service.
In the previous exemple, we declared a `bar` filesystem:
``` php
$container->get('knp_gaufrette.filesystem_map')->get('bar');
```
Returns the instance of `Gaufrette\Filesystem` for `bar`.
Returns the `bar` instance of `Gaufrette\Filesystem`.
Adapters Reference
------------------
## Local Adapter
## Local Adapter (local)
A simple local filesystem based adapter.
@@ -224,6 +230,45 @@ knp_gaufrette:
mtime: 123456890123
```
## Azure Blob Storage (azure\_blob\_storage)
Adapter for Microsoft Azure Blob Storage service. To use this adapter you need to install the
[Azure SDK for php](http://www.windowsazure.com/en-us/develop/php/common-tasks/download-php-sdk/) into your project.
Further more you need a valid *connection string* and you must define a Blob Proxy factory service with it. You can use
the default `\Gaufrette\Adapter\AzureBlobStorage\BlobProxyFactory` this way:
``` yaml
# app/config/config.yml
services:
azure_blob_proxy_factory:
class: Gaufrette\Adapter\AzureBlobStorage\BlobProxyFactory
arguments: [%azure_blob_storage_connection_string%]
```
You must set the parameter `azure_blob_storage_connection_string` to contain your windows azure blob storage connection
string. You can retrieve your connection string in your [Windows Azure management console](https://manage.windowsazure.com).
### Parameters
* `blob_proxy_factory_id` Reference to the blob proxy factory service
* `container_name` The name of the container
* `create_container` Boolean value that indicates whether to create the container if it does not exists (*optional*: default *false*)
* `detect_content_type` Boolean value that indicates whether to auto determinate and set the content type on new blobs (*optional*: default *true*)
### Example
``` yaml
# app/config/config.yml
knp_gaufrette:
adapters:
foo:
azure_blob_storage:
blob_proxy_factory_id: azure_blob_proxy_factory
container_name: my_container
create_container: true
```
## GridFS (gridfs)
Adapter that allows you to use a MongoDB GridFS for storing files.
@@ -265,7 +310,7 @@ services:
arguments: [@acme_test.mongodb, %acme_test.gridfs.prefix%]
```
Note that it is possible to prepare MongoGridFS service anyway you like. This is just one way to do it.
Note that it is possible to prepare MongoGridFS service any way you like. This is just one way to do it.
## MogileFS (mogilefs)
@@ -288,15 +333,13 @@ knp_gaufrette:
hosts: ["192.168.0.1:7001", "192.168.0.2:7001"]
```
[gaufrette-homepage]: https://github.com/KnpLabs/Gaufrette
## Ftp
## Ftp (ftp)
Adapter for FTP.
### Parameters
* `directory` The directory of the filesystem *(required)*
* `directory` The remote directory *(required)*
* `host` FTP host *(required)*
* `username` FTP username *(default null)*
* `password` FTP password *(default null)*
@@ -321,14 +364,14 @@ knp_gaufrette:
mode: FTP_BINARY
```
## Sftp
## Sftp (sftp)
Adapter for SFTP (SSH-FTP).
### Parameters
* `sftp_id` The id of the service that provides SFTP access.
* `directory* The distant directory *(default null)*.
* `directory` The remote directory *(default null)*.
* `create` Whether to create the directory if it does not exist *(default false)*.
### Example
@@ -371,7 +414,7 @@ services:
arguments: [@acme_test.ssh.session]
```
## Apc
## Apc (apc)
Adapter for APC.
@@ -394,9 +437,213 @@ knp_gaufrette:
ttl: 0
```
## Cache
## Amazon S3 (amazon_s3)
Adapter which allow to cache other adapters
Adapter to connect to Amazon S3 instances.
This adapter requires the use of amazonwebservices/aws-sdk-for-php which can be installed by adding the following line to your composer.json:
```
"require": {
...
"amazonwebservices/aws-sdk-for-php": "1.6.2"
},
```
### Parameters
* `amazon_s3_id`: the id of the AmazonS3 service used for the underlying connection
* `bucket_name`: the name of the bucket to use
* `options`: additional (optional) settings
* `directory`: the directory to use, within the specified bucket
* `region`
* `create`
### Defining services
To use the Amazon S3 adapter you need to provide a valid `AmazonS3` instance (as defined in the Amazon SDK). This can
easily be set up as using Symfony's service configuration:
``` yaml
# app/config/config.yml
services:
amazonS3:
class: AmazonS3
arguments:
options:
key: '%aws_key%'
secret: '%aws_secret_key%'
```
### Example
Once the service is set up use its key as the amazon_s3_id in the gaufrette configuration:
``` yaml
# app/config/config.yml
knp_gaufrette:
adapters:
foo:
amazon_s3:
amazon_s3_id: amazonS3
bucket_name: foo_bucket
options:
directory: foo_directory
```
Note that the SDK seems to have some issues with bucket names with dots in them, e.g. "com.mycompany.bucket" seems to have issues but "com-mycompany-bucket" works.
## AwsS3
Adapter for Amazon S3 SDK v2.
### Parameters
* `service_id` The service id of the `Aws\S3\S3Client` to use. *(required)*
* `bucket_name` The name of the S3 bucket to use. *(required)*
* `options` A list of additional options passed to the adapter.
* `create` Whether to create the bucket if it doesn't exist. *(default false)*
* `directory` A directory to operate in. *(default '')*
This directory will be created in the root of the bucket and all files will be read and written there.
### Defining services
An example service definition of the `Aws\S3\S3Client`:
```yaml
services:
acme.aws_s3.client:
class: Aws\S3\S3Client
factory_class: Aws\S3\S3Client
factory_method: 'factory'
arguments:
-
key: %amazon_s3.key%
secret: %amazon_s3.secret%
region: %amazon_s3.region%
```
### Example
Once the service is set up use its key as the `service_id` in the gaufrette configuration:
``` yaml
# app/config/config.yml
knp_gaufrette:
adapters:
profile_photos:
aws_s3:
service_id: 'acme.aws_s3.client'
bucket_name: 'images'
options:
directory: 'profile_photos'
```
## Open Cloud (opencloud)
Adapter for OpenCloud (Rackspace)
### Parameters
* `object_store_id`: the id of the object store service
* `container_name`: the name of the container to use
* `create_container`: if `true` will create the container if it doesn't exist *(default `false`)*
* `detect_content_type`: if `true` will detect the content type for each file *(default `true`)*
### Defining services
To use the OpenCloud adapter you should provide a valid `ObjectStore` instance. You can retrieve an instance through the
`OpenCloud\OpenStack` or `OpenCloud\Rackspace` instances. We can provide a comprehensive configuration through the Symfony
DIC configuration.
#### Define OpenStack/Rackspace service
Generic OpenStack:
``` yaml
# app/config/config.yml
services:
opencloud.connection:
class: OpenCloud\OpenStack
arguments:
- %openstack_identity_url%
- {username: %openstack_username%, password: %openstack_password%, tenantName: %openstack_tenant_name%}
```
HPCloud:
``` yaml
# app/config/config.yml
services:
opencloud.connection.hpcloud:
class: OpenCloud\OpenStack
arguments:
- 'https://region-a.geo-1.identity.hpcloudsvc.com:123456/v2.0/' // check https://account.hpcloud.com/account/api_keys for identities urls
- {username: %hpcloud_username%, password: %hpcloud_password%, tenantName: %hpcloud_tenant_name%}
```
The username and password are your login credentials, not the api key. Your tenantName is your Project Name on the api keys page.
Rackspace:
``` yaml
# app/config/config.yml
services:
opencloud.connection.rackspace:
class: OpenCloud\Rackspace
arguments:
- 'https://identity.api.rackspacecloud.com/v2.0/'
- {username: %rackspace_username%, apiKey: %rackspace_apikey%}
```
#### Define ObjectStore service
HPCloud:
``` yaml
# app/config/config.yml
services:
opencloud.object_store:
class: OpenCloud\ObjectStoreBase
factory_service: opencloud.connection.hpcloud
factory_method: ObjectStore
arguments:
- 'Object Storage' # Object storage type
- 'region-a.geo-1' # Object storage region
- 'publicURL' # url type
```
Rackspace:
``` yaml
# app/config/config.yml
services:
opencloud.object_store:
class: OpenCloud\ObjectStoreBase
factory_service: opencloud.connection
factory_method: ObjectStore
arguments:
- 'cloudFiles' # Object storage type
- 'DFW' # Object storage region
- 'publicURL' # url type
```
### Example
Finally you can define your adapter in configuration:
``` yaml
# app/config/config.yml
knp_gaufrette:
adapters:
foo:
opencloud:
object_store_id: opencloud.object_store
container_name: foo
```
## Cache (cache)
Adapter which allows you to cache other adapters
### Parameters
@@ -435,18 +682,20 @@ knp_gaufrette:
## Stream Wrapper
You can register filesystems with a specified domain.
And use as a stream wrapper anywhere in your code like :
The `stream_wrapper` settings allow you to register filesystems with a specified domain and
then use as a stream wrapper anywhere in your code like:
`gaufrette://domain/file.txt`
### Parameters
* `protocol` The protocol name like `gaufrette://…` *(default gaufrette)*
* `filesystem` An array that contains files systems that you want to register with the possibility to set the key of the array
as the domain like `gaufrette://mydomain/…` *(default all filesystems)*
* `filesystem` An array that contains filesystems that you want to register to this stream_wrapper.
If you set array keys these will be used as an alias for the filesystem (see examples below) *(default all filesystems without aliases)*
### Example 1
The protocol is gaufrette and all filesystems will be saved
Using default settings, the protocol is "gaufrette" and all filesystems will be served
``` yaml
# app/config/config.yml
knp_gaufrette:
@@ -464,12 +713,14 @@ knp_gaufrette:
```
```
gaufrette://backup1/file
gaufrette://amazonS3/file
gaufrette://backup1/...
gaufrette://amazonS3/...
```
### Example 2
We define the protocol as data and all filesystem will be saved
We define the protocol as "data", all filesystem will still be served (by default)
``` yaml
# app/config/config.yml
knp_gaufrette:
@@ -486,7 +737,9 @@ data://amazonS3/...
```
### Example 3
We define the protocol as data and define which filesystem will be used
We define the protocol as data and define which filesystem(s) will be available
``` yaml
# app/config/config.yml
knp_gaufrette:
@@ -497,15 +750,16 @@ knp_gaufrette:
protocol: data
filesystems:
- backup1
- amazonS3
```
```
data://backup1/...
data://amazonS3/...
data://backup1/... (works since it is defined above)
data://amazonS3/... (will not be available)
```
### Example 4
We define the protocol as data and define which filesystem will be used with the domain aliasing
We define the protocol as data and define which filesystems will be available using array keys to set domain aliases
``` yaml
# app/config/config.yml
@@ -523,4 +777,78 @@ knp_gaufrette:
```
data://backup/...
data://pictures/...
```
```
## Doctrine DBAL (doctrine_dbal)
Adapter that allows you to store data into a database.
### Parameters
* `connection_name` The doctrine dbal connection name like `default`
* `table` The table name like `media_data`
* `key`: The primary key in the table
* `content`: The field name of the file content
* `mtime`: The field name of the timestamp
* `checksum`: The field name of the checksum
### Example
``` yaml
# app/config/config.yml
knp_gaufrette:
adapters:
database:
doctrine_dbal:
connection_name: default
table: data
columns:
key: id
content: text
mtime: date
checksum: checksum
```
## Dropbox (dropbox)
Adapter for Dropbox.
### Parameters
* `api_id` The id of the service that provides Dropbox API access.
### Example
> In order to get a Dropbox token and token_secret, you need to add a new Dropbox App in your account, and then you'll need to go through the oAuth authorization process
``` yaml
# app/config/config.yml
knp_gaufrette:
adapters:
foo:
dropbox:
api_id: acme_test.dropbox.api
```
In your AcmeTestBundle, add following service definitions:
``` yaml
# src/Acme/TestBundle/Resources/config/services.yml
parameters:
acme_test.dropbox.key: my_consumer_key
acme_test.dropbox.secret: my_consumer_secret
acme_test.dropbox.token: some_token
acme_test.dropbox.token_secret: some_token_secret
services:
acme_test.dropbox.oauth:
class: Dropbox_OAuth_Curl
arguments: [%acme_test.dropbox.key%, %acme_test.dropbox.secret%]
calls:
- [setToken, ["%acme_test.dropbox.token%", "%acme_test.dropbox.token_secret%"]]
acme_test.dropbox.api:
class: Dropbox_API
arguments: [@acme_test.dropbox.oauth, "sandbox"]
```
[gaufrette-homepage]: https://github.com/KnpLabs/Gaufrette

View File

@@ -20,9 +20,21 @@
<service id="knp_gaufrette.adapter.factory.amazon_s3" class="Knp\Bundle\GaufretteBundle\DependencyInjection\Factory\AmazonS3AdapterFactory">
<tag name="gaufrette.adapter.factory" />
</service>
<service id="knp_gaufrette.adapter.factory.aws_s3" class="Knp\Bundle\GaufretteBundle\DependencyInjection\Factory\AwsS3AdapterFactory">
<tag name="gaufrette.adapter.factory" />
</service>
<service id="knp_gaufrette.adapter.factory.acl_aware_amazon_s3" class="Knp\Bundle\GaufretteBundle\DependencyInjection\Factory\AclAwareAmazonS3AdapterFactory">
<tag name="gaufrette.adapter.factory" />
</service>
<service id="knp_gaufrette.adapter.factory.doctrine_dbal" class="Knp\Bundle\GaufretteBundle\DependencyInjection\Factory\DoctrineDbalAdapterFactory">
<tag name="gaufrette.adapter.factory" />
</service>
<service id="knp_gaufrette.adapter.factory.opencloud" class="Knp\Bundle\GaufretteBundle\DependencyInjection\Factory\OpenCloudAdapterFactory">
<tag name="gaufrette.adapter.factory" />
</service>
<service id="knp_gaufrette.adapter.factory.azure_blob_storage" class="Knp\Bundle\GaufretteBundle\DependencyInjection\Factory\AzureBlobStorageAdapterFactory">
<tag name="gaufrette.adapter.factory" />
</service>
<service id="knp_gaufrette.adapter.factory.gridfs" class="Knp\Bundle\GaufretteBundle\DependencyInjection\Factory\GridFSAdapterFactory">
<tag name="gaufrette.adapter.factory" />
</service>
@@ -41,7 +53,9 @@
<service id="knp_gaufrette.adapter.factory.cache" class="Knp\Bundle\GaufretteBundle\DependencyInjection\Factory\CacheAdapterFactory">
<tag name="gaufrette.adapter.factory" />
</service>
<service id="knp_gaufrette.adapter.factory.dropbox" class="Knp\Bundle\GaufretteBundle\DependencyInjection\Factory\DropboxAdapterFactory">
<tag name="gaufrette.adapter.factory" />
</service>
</services>
</container>

View File

@@ -23,7 +23,16 @@
<argument /><!-- Create -->
</service>
<service id="knp_gaufrette.adapter.amazon_s3" class="Gaufrette\Adapter\AmazonS3" abstract="true" public="false" />
<service id="knp_gaufrette.adapter.aws_s3" class="Gaufrette\Adapter\AwsS3" abstract="true" public="false" />
<service id="knp_gaufrette.adapter.doctrine_dbal" class="Gaufrette\Adapter\DoctrineDbal" abstract="true" public="false" />
<service id="knp_gaufrette.adapter.acl_aware_amazon_s3" class="Gaufrette\Adapter\AclAwareAmazonS3" abstract="true" public="false" />
<service id="knp_gaufrette.adapter.opencloud" class="Gaufrette\Adapter\OpenCloud" abstract="true" public="false">
<argument /><!-- ObjectStore -->
<argument /><!-- Container name -->
<argument /><!-- Create container -->
<argument /><!-- Detect content type -->
</service>
<service id="knp_gaufrette.adapter.azure_blob_storage" class="Gaufrette\Adapter\AzureBlobStorage" abstract="true" public="false" />
<service id="knp_gaufrette.adapter.gridfs" class="Gaufrette\Adapter\GridFS" abstract="true" public="false" />
<service id="knp_gaufrette.adapter.mogilefs" class="Gaufrette\Adapter\MogileFS" abstract="true" public="false">
<argument /><!-- domain -->
@@ -39,6 +48,7 @@
<service id="knp_gaufrette.filesystem_map" class="%knp_gaufrette.filesystem_map.class%">
<argument /> <!-- map of filesystems -->
</service>
<service id="knp_gaufrette.adapter.dropbox" class="Gaufrette\Adapter\Dropbox" abstract="true" public="false" />
</services>
</container>

View File

@@ -34,6 +34,7 @@ class ConfigurationTest extends \PHPUnit_Framework_TestCase
/**
* @test
* @functional
*/
public function shouldAllowForFilesystemAlias()
{
@@ -42,6 +43,7 @@ class ConfigurationTest extends \PHPUnit_Framework_TestCase
/**
* @test
* @functional
*/
public function shouldWorkForOtherEnv()
{
@@ -54,6 +56,7 @@ class ConfigurationTest extends \PHPUnit_Framework_TestCase
/**
* @test
* @functional
*/
public function shouldAllowAccessToAllPublicServices()
{
@@ -70,6 +73,7 @@ class ConfigurationTest extends \PHPUnit_Framework_TestCase
/**
* @test
* @functional
*/
public function shouldAllowAccessToLocalFilesystem()
{
@@ -78,6 +82,7 @@ class ConfigurationTest extends \PHPUnit_Framework_TestCase
/**
* @test
* @functional
*/
public function shouldAllowAccessToCacheFilesystem()
{
@@ -86,6 +91,7 @@ class ConfigurationTest extends \PHPUnit_Framework_TestCase
/**
* @test
* @functional
*/
public function shouldAllowAccessToFtpFilesystem()
{
@@ -94,6 +100,7 @@ class ConfigurationTest extends \PHPUnit_Framework_TestCase
/**
* @test
* @functional
*/
public function shouldAllowToNotConfigureStreamWrapper()
{
@@ -102,6 +109,7 @@ class ConfigurationTest extends \PHPUnit_Framework_TestCase
/**
* @test
* @functional
*/
public function shouldConfigureStreamWrapperWithDefaultValues()
{
@@ -127,6 +135,7 @@ class ConfigurationTest extends \PHPUnit_Framework_TestCase
/**
* @test
* @functional
*/
public function shouldAllowToDefineProtocolOfStreamWrapper()
{
@@ -140,6 +149,7 @@ class ConfigurationTest extends \PHPUnit_Framework_TestCase
/**
* @test
* @functional
*/
public function shouldAllowToDefineWhichFileSystemsShouldBeAddToStreamWrapper()
{
@@ -159,6 +169,7 @@ class ConfigurationTest extends \PHPUnit_Framework_TestCase
/**
* @test
* @functional
*/
public function shouldAllowToDefineFileSystemsWithoutDomain()
{

View File

@@ -17,11 +17,12 @@
],
"require": {
"symfony/framework-bundle": "2.*",
"knplabs/gaufrette": "0.1.4"
"knplabs/gaufrette": "~0.1.7"
},
"require-dev": {
"symfony/yaml": "2.*",
"symfony/console": "2.*"
"symfony/console": "2.*",
"phpunit/phpunit": "3.7.*"
},
"autoload": {
"psr-0": {
@@ -33,5 +34,8 @@
"dev-master": "0.2.x-dev"
}
},
"config": {
"bin-dir": "bin"
},
"target-dir": "Knp/Bundle/GaufretteBundle"
}