Open a command console, enter your project directory and execute the following command to download the latest stable version of this bundle:
$ composer require px/multi-file-system-bundle "~1"This command requires you to have Composer installed globally, as explained in the installation chapter of the Composer documentation.
Then, enable the bundle by adding it to the list of registered bundles
in the app/AppKernel.php file of your project:
<?php
// app/AppKernel.php
// ...
class AppKernel extends Kernel
{
public function registerBundles()
{
$bundles = array(
// ...
new Px\MultiFileSystemBundle\PxMultiFileSystemBundle(),
);
// ...
}
// ...
}The bundle allows you to declare your adapters as services.
The configuration of the bundle is divided into two parts: the contexts and the adapters.
# app/config/config.yml
px_multi_file_system:
contexts:
user_profile:
directory: '/path/to/directory'A simple local filesystem based adapter.
directoryThe directory of the filesystem (required)createWhether to create the directory if it does not exist (default true)
# app/config/config.yml
px_multi_file_system:
adapters:
foo:
local:
directory: /path/to/directory
create: truecreateWhether to create the bucket if it doesn't exist. (default false)directoryA directory to operate in. (default '')s3_configA list of additional options passed to the adapter. This directory will be created in the root of the bucket and all files will be read and written there.aclDefault ACL to apply to the objectsbucket_nameThe name of the S3 bucket to use. (required)versionThe version of the S3 bucket to use. (required)credentialsThe credentials of the S3 bucket to use. (required)
# app/config/config.yml
px_multi_file_system:
adapters:
profile_photos:
aws_s3:
directory: 'default'
create: true
s3_config:
bucket_name: %amazon_s3.bucket%
version: latest
region: %amazon_s3.region%
credentials:
key: %amazon_s3.key%
secret: %amazon_s3.secret%