24 Commits

Author SHA1 Message Date
Andrew Kovalyov
44cf552e14 Add travis badge 2016-01-16 02:12:11 +02:00
Andrew Kovalyov
59afa91134 Rename README.markdown to README.md 2016-01-16 02:11:43 +02:00
Andrew Kovalyov
988188477f Prepare for 0.3 2016-01-16 02:08:29 +02:00
Albin Kerouanton
45dc19248b Merge pull request #127 from tgabi333/sf3
[WIP] allow symfony3
2015-12-07 11:14:48 +01:00
Tóth Gábor
ad36fa50d0 allow sf3 2015-12-03 19:29:31 +01:00
Florian Klein
0b2750033a Merge pull request #102 from Karisch/feature/google-cloud-storage
Add support for Google Cloud Storage
2015-11-10 10:25:29 +01:00
Yann Rabiller
7edea6cfcc Merge pull request #115 from diimpp/patch-1
Fix typo in phpseclib adapter's readme example
2015-09-18 14:09:25 +02:00
Andrew Kovalyov
bf9652537f Add a note about Dropbox 2015-09-11 15:08:19 +03:00
Florian Klein
b6dbd93d12 Merge pull request #117 from stof/patch-1
Improve the composer.json
2015-08-31 08:57:20 +02:00
Christophe Coevoet
b8596b4ca1 Improve the composer.json
- allow both stable and dev versions of Gaufrette to make the usage of the bundle easier
- switch autoloading to PSR-4 rather than using the legacy "target-dir" setting
- change the PHPUnit requirement to use maintained versions
2015-08-05 11:24:03 +02:00
Dmitri Perunov
0536334f7c Fix typo in phpseclib adapter's readme example 2015-05-14 11:44:58 +05:00
Florian Klein
b928e97767 Merge pull request #108 from diimpp/phpseclibsftp_adapter
Add phpseclib sftp adapter
2015-05-11 09:02:46 +02:00
Florian Klein
6878189ba2 Merge pull request #94 from escapestudios/master
ObjectStore-method became objectStoreService-method in php-opencloud
2015-04-21 16:42:49 +00:00
Dmitri Perunov
5b1463cdc5 Add phpseclib sftp adapter 2015-02-10 16:28:08 +06:00
Patrik Karisch
65f587ae17 Add documentation 2014-11-01 12:28:12 +01:00
Patrik Karisch
db25e67b10 Add support for Google Cloud Storage 2014-11-01 12:27:35 +01:00
Leszek Prabucki
c88039e80c Merge pull request #96 from pilot/master
Remove support symfony 2.0 deps instruction
2014-07-08 18:28:42 +02:00
Alex Demchenko
a075802e29 Remove support symfony 2.0 deps instruction 2014-07-08 17:50:44 +03:00
David Joos
b6d58c99c3 ObjectStore-method became objectStoreService-method in php-opencloud
Fixes "call to undefined method OpenCloud\Rackspace::ObjectStore()" we were experiencing...
2014-06-19 14:42:41 +01:00
Leszek Prabucki
ce0e00c554 Merge pull request #91 from bmeynell/master
added detect_content_type option for AwsS3 adapter
2014-06-03 10:10:53 +02:00
Leszek Prabucki
b2a387580e Merge pull request #85 from kbond/config-dump
Enable dumping of config
2014-06-03 10:09:31 +02:00
Ben Meynell
d1eb6f2550 added detect_content_type option for AwsS3 adapter 2014-05-05 09:10:50 -04:00
Kevin Bond
ef57204cd5 enable dumping of config 2014-04-08 14:41:46 -04:00
l3l0
ae598e6114 Allows to latest gaufrette version at master 2014-03-27 09:59:55 +01:00
9 changed files with 258 additions and 68 deletions

View File

@@ -1,12 +1,33 @@
language: php
sudo: false
php:
- 5.3
- 5.4
- 5.5
- 5.6
- 7.0
before_script:
- curl -s http://getcomposer.org/installer | php -- --quiet
- php composer.phar install --dev
cache:
directories:
- $HOME/.composer/cache
matrix:
include:
- php: 5.6
env: SYMFONY_VERSION='~2.3'
- php: 5.6
env: SYMFONY_VERSION='~2.8'
- php: 5.6
env: SYMFONY_VERSION='~3.0'
before_install:
- composer self-update
- sh -c 'if [ "$SYMFONY_VERSION" != "" ]; then composer require --no-update symfony/symfony=$SYMFONY_VERSION; fi;'
install: composer install
script:
- php bin/phpunit --coverage-text

View File

@@ -20,6 +20,7 @@ class AwsS3AdapterFactory implements AdapterFactoryInterface
->addArgument(new Reference($config['service_id']))
->addArgument($config['bucket_name'])
->addArgument($config['options'])
->addArgument($config['detect_content_type'])
;
}
@@ -40,6 +41,7 @@ class AwsS3AdapterFactory implements AdapterFactoryInterface
->children()
->scalarNode('service_id')->isRequired()->cannotBeEmpty()->end()
->scalarNode('bucket_name')->isRequired()->cannotBeEmpty()->end()
->booleanNode('detect_content_type')->defaultFalse()->end()
->arrayNode('options')
->addDefaultsIfNotSet()
->children()

View File

@@ -0,0 +1,55 @@
<?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 GoogleCloudStorageAdapterFactory implements AdapterFactoryInterface
{
/**
* {@inheritDoc}
*/
public function create(ContainerBuilder $container, $id, array $config)
{
$container
->setDefinition($id, new DefinitionDecorator('knp_gaufrette.adapter.google_cloud_storage'))
->addArgument(new Reference($config['service_id']))
->addArgument($config['bucket_name'])
->addArgument($config['options'])
->addArgument($config['detect_content_type'])
;
}
/**
* {@inheritDoc}
*/
public function getKey()
{
return 'google_cloud_storage';
}
/**
* {@inheritDoc}
*/
public function addConfiguration(NodeDefinition $builder)
{
$builder
->children()
->scalarNode('service_id')->isRequired()->cannotBeEmpty()->end()
->scalarNode('bucket_name')->isRequired()->cannotBeEmpty()->end()
->booleanNode('detect_content_type')->defaultTrue()->end()
->arrayNode('options')
->addDefaultsIfNotSet()
->children()
->scalarNode('directory')->defaultValue('')->end()
->scalarNode('acl')->defaultValue('private')->end()
->end()
->end()
->end()
;
}
}

View File

@@ -0,0 +1,49 @@
<?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;
/**
* Phpseclib Sftp Adapter Factory
*/
class PhpseclibSftpAdapterFactory implements AdapterFactoryInterface
{
/**
* {@inheritDoc}
*/
function create(ContainerBuilder $container, $id, array $config)
{
$container
->setDefinition($id, new DefinitionDecorator('knp_gaufrette.adapter.phpseclib_sftp'))
->addArgument(new Reference($config['phpseclib_sftp_id']))
->addArgument($config['directory'])
->addArgument($config['create'])
;
}
/**
* {@inheritDoc}
*/
function getKey()
{
return 'phpseclib_sftp';
}
/**
* {@inheritDoc}
*/
function addConfiguration(NodeDefinition $builder)
{
$builder
->children()
->scalarNode('phpseclib_sftp_id')->isRequired()->end()
->scalarNode('directory')->defaultNull()->end()
->booleanNode('create')->defaultFalse()->end()
->end()
;
}
}

View File

@@ -28,21 +28,15 @@ class KnpGaufretteExtension extends Extension
public function load(array $configs, ContainerBuilder $container)
{
$processor = new Processor();
// first assemble the adapter factories
$factoryConfig = new FactoryConfiguration();
$config = $processor->processConfiguration($factoryConfig, $configs);
$factories = $this->createAdapterFactories($config, $container);
// then normalize the configs
$mainConfig = new MainConfiguration($factories);
$config = $processor->processConfiguration($mainConfig, $configs);
$config = $processor->processConfiguration($this->getConfiguration($configs, $container), $configs);
$loader = new XmlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config'));
$loader->load('gaufrette.xml');
$adapters = array();
foreach ($config['adapters'] as $name => $adapter) {
$adapters[$name] = $this->createAdapter($name, $adapter, $container, $factories);
$adapters[$name] = $this->createAdapter($name, $adapter, $container, $this->factories);
}
$map = array();
@@ -59,6 +53,19 @@ class KnpGaufretteExtension extends Extension
}
}
public function getConfiguration(array $configs, ContainerBuilder $container)
{
$processor = new Processor();
// first assemble the adapter factories
$factoryConfig = new FactoryConfiguration();
$config = $processor->processConfiguration($factoryConfig, $configs);
$factories = $this->createAdapterFactories($config, $container);
// then normalize the configs
return new MainConfiguration($factories);
}
private function createAdapter($name, array $config, ContainerBuilder $container, array $factories)
{
$adapter = null;

View File

@@ -1,6 +1,8 @@
Gaufrette Bundle
================
[![Build Status](https://travis-ci.org/KnpLabs/KnpGaufretteBundle.svg?branch=master)](https://travis-ci.org/KnpLabs/KnpGaufretteBundle)
Provides a [Gaufrette][gaufrette-homepage] integration for your Symfony projects.
About Gaufrette
@@ -18,56 +20,17 @@ Installation
As this bundle is an integration for Symfony of the [Gaufrette][gaufrette-homepage] library, it requires you to first install [Gaufrette][gaufrette-homepage] in a Symfony project.
## Download the bundle
## With composer
You can download an archive of the bundle and unpack it in the `vendor/bundles/Knp/Bundle/GaufretteBundle` directory of your application.
This bundle can be installed using [composer](http://getcomposer.org) by adding the following in the `require` section of your `composer.json` file:
### Standard Edition Style
If you are using the `deps` file to manage your project's dependencies,
you must add the following lines to it:
[gaufrette]
git=http://github.com/KnpLabs/Gaufrette.git
[KnpGaufretteBundle]
git=http://github.com/KnpLabs/KnpGaufretteBundle.git
target=/bundles/Knp/Bundle/GaufretteBundle
### Composer Style
This bundle can be installed using composer by adding the following in the `require` section of your `composer.json` file:
```
``` json
"require": {
...
"knplabs/knp-gaufrette-bundle": "dev-master"
"knplabs/knp-gaufrette-bundle": "*@dev"
},
```
### Git Submodule Style
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
You must register both Gaufrette and the KnpGaufretteBundle in your autoloader:
(You do not have to do this if you are using the composer autoload system.)
``` php
<?php
// app/autoload.php
$loader->addClassMap(array(
'Knp\Bundle' => __DIR__.'/../vendor/bundles',
'Gaufrette' => __DIR__.'/../vendor/gaufrette/src',
// ...
));
```
## Register the bundle
You must register the bundle in your kernel:
@@ -414,6 +377,47 @@ services:
arguments: [@acme_test.ssh.session]
```
## Phpseclib Sftp (phpseclib_sftp)
Adapter for phpseclib SFTP (SSH-FTP).
### Parameters
* `phpseclib_sftp_id` The id of the service that provides SFTP access.
* `directory` The remote directory *(default null)*.
* `create` Whether to create the directory if it does not exist *(default false)*.
### Example
``` yaml
# app/config/config.yml
knp_gaufrette:
adapters:
foo:
phpseclib_sftp:
phpseclib_sftp_id: acme_test.sftp
directory: /example/sftp
create: true
```
In your AcmeTestBundle, add following service definitions:
``` yaml
# src/Acme/TestBundle/Resources/config/services.yml
parameters:
acme_test.ssh.host: my_host_name
acme_test.ssh.username: user_name
acme_test.ssh.password: some_secret
services:
acme_test.sftp:
class: Net_SFTP
arguments: [%acme_test.ssh.host%]
calls:
- [login, [%acme_test.ssh.username%, %acme_test.ssh.password%]]
```
## Apc (apc)
Adapter for APC.
@@ -620,7 +624,7 @@ services:
opencloud.object_store:
class: OpenCloud\ObjectStoreBase
factory_service: opencloud.connection
factory_method: ObjectStore
factory_method: objectStoreService
arguments:
- 'cloudFiles' # Object storage type
- 'DFW' # Object storage region
@@ -641,6 +645,51 @@ knp_gaufrette:
container_name: foo
```
## GoogleCloudStorage
Adapter for Google APIs Client Library for PHP.
### Parameters
* `service_id` The service id of the `\Google_Service_Storage` to use. *(required)*
* `bucket_name` The name of the GCS bucket to use. *(required)*
* `detect_content_type`: if `true` will detect the content type for each file *(default `true`)*
* `options` A list of additional options passed to the adapter.
* `directory` A directory to operate in. *(default '')*
* `acl` Whether the uploaded files should be `private` or `public` *(default `private`)*
### Defining services
You need to create a custom factory service which creates a `\Google_Client` and authorizes with the correct scopes
and then returns a `\Google_Service_Storage` class connected to the client class:
```yaml
services:
app.google_cloud_storage.service:
class: \Google_Service_Storage
factory_class: App\Factory\GoogleCloudStorageServiceFactory
factory_method: 'createService'
arguments:
-
# all the arguments needed like service account email and path to key.p12
```
### 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:
google_cloud_storage:
service_id: 'app.google_cloud_storage.service'
bucket_name: 'images'
options:
directory: 'profile_photos'
```
## Cache (cache)
Adapter which allows you to cache other adapters
@@ -811,7 +860,7 @@ knp_gaufrette:
## Dropbox (dropbox)
Adapter for Dropbox.
Adapter for Dropbox. In order to use it, you should add `dropbox-php/dropbox-php` as your composer dependency.
### Parameters

View File

@@ -35,6 +35,9 @@
<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.google_cloud_storage" class="Knp\Bundle\GaufretteBundle\DependencyInjection\Factory\GoogleCloudStorageAdapterFactory">
<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>
@@ -47,6 +50,9 @@
<service id="knp_gaufrette.adapter.factory.sftp" class="Knp\Bundle\GaufretteBundle\DependencyInjection\Factory\SftpAdapterFactory">
<tag name="gaufrette.adapter.factory" />
</service>
<service id="knp_gaufrette.adapter.factory.phpseclib_sftp" class="Knp\Bundle\GaufretteBundle\DependencyInjection\Factory\PhpseclibSftpAdapterFactory">
<tag name="gaufrette.adapter.factory" />
</service>
<service id="knp_gaufrette.adapter.factory.apc" class="Knp\Bundle\GaufretteBundle\DependencyInjection\Factory\ApcAdapterFactory">
<tag name="gaufrette.adapter.factory" />
</service>

View File

@@ -33,6 +33,7 @@
<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.google_cloud_storage" class="Gaufrette\Adapter\GoogleCloudStorage" 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 -->
@@ -40,6 +41,7 @@
</service>
<service id="knp_gaufrette.adapter.ftp" class="Gaufrette\Adapter\Ftp" abstract="true" public="false" />
<service id="knp_gaufrette.adapter.sftp" class="Gaufrette\Adapter\Sftp" abstract="true" public="false" />
<service id="knp_gaufrette.adapter.phpseclib_sftp" class="Gaufrette\Adapter\PhpseclibSftp" abstract="true" public="false" />
<service id="knp_gaufrette.adapter.apc" class="Gaufrette\Adapter\Apc" abstract="true" public="false">
<argument /><!-- prefix -->
<argument /><!-- ttl -->

View File

@@ -16,26 +16,25 @@
}
],
"require": {
"symfony/framework-bundle": "2.*",
"knplabs/gaufrette": "~0.1.7"
"symfony/framework-bundle": "~2.0|~3.0",
"knplabs/gaufrette": "~0.1.7|~0.2"
},
"require-dev": {
"symfony/yaml": "2.*",
"symfony/console": "2.*",
"phpunit/phpunit": "3.7.*"
"symfony/yaml": "~2.0|~3.0",
"symfony/console": "~2.0|~3.0",
"phpunit/phpunit": "~4.2"
},
"autoload": {
"psr-0": {
"Knp\\Bundle\\GaufretteBundle": ""
"psr-4": {
"Knp\\Bundle\\GaufretteBundle\\": ""
}
},
"extra": {
"branch-alias": {
"dev-master": "0.2.x-dev"
"dev-master": "0.4.x-dev"
}
},
"config": {
"bin-dir": "bin"
},
"target-dir": "Knp/Bundle/GaufretteBundle"
}
}