dbAmazonS3Plugin - 1.0.3

This plugin will allow you to easily move/transfer your assets to amazon s3

You are currently browsing
the website for symfony 1

Visit the Symfony2 website

« Back to the Plugins Home


Forgot your password?
Create an account



advanced search
Information Readme Releases Changelog Contribute
Show source

dbAmazonS3 plugin

The dbAmazonS3Plugin is a symfony plugin that makes using the Amazon S3 cloud (even more) easy!


  • Install the plugin

    $ symfony plugin:install dbAmazonS3Plugin
  • Enable the plugin in your ProjectConfiguration:

    class ProjectConfiguration extends sfProjectConfiguration
      public function setup()
  • Create an AWS account at http://aws.amazon.com/s3/

  • Set your bucket-url & aws-keys in app.yml, and set enable to true for the environments you want, for example:

        enabled:              false #default
        bucket:               bucket-name
        bucket_url:           http://s3.amazonaws.com/bucket-name
        aws_key:              aws_key
        aws_secret_key:       aws_secret-key
        stylesheets_prefix:   s3 #default, dir where the css-files are stored (under web/css) containing absolute urls (to S3 cloud), used when amazon_s3 is enabled
        prefixed_stylesheets: [ foo.css, bar.css ] #default empty array
          enabled:            true
    • Add AmazonS3 to your standard helpers in settings.yml

      [yml] all: actions: standard_helpers: [Partial, Cache, Form, I18N, AutoLanguage, diba, db, AmazonS3 ] [/yml]

    • In your layout files: replace include_stylesheets() & include_javascripts() helper calls with include_stylesheets_s3() & include_javascripts_s3()

    • In all your template files: replace image_tag() helper calls with image_tag_s3
    • To synchronize your assets to the Amazon S3 bucket (defined by app_amazon_s3_bucket), run the sync S3 task (by default your whole web folder is synced)

      ./symfony s3:sync-files [--directory="/css"]

      ** Note 1: If the bucket doesn't exist, this task will create it for you! ** Note 2: At the moment this task doesn't really sync, rather it deletes all files and uploads them again.

CSS files containing URI's & sgLESS

  • If your css files contain URI's, for example if you use background images, then they wouldn't be loaded from the Amazon cloud. You can opt to have two versions of those files: one with the relative url, and thus pointing to your local server, and one which points to the cloud. If you choose to do so, then the files with URI's pointing to the cloud should be in the folder defined by app_amazon_s3_stylesheets_prefix. You should also define which those files are, and if s3 is enabled (can be different per environment) the AmazonS3Helper will load them from this new directory. If it's not enabled, the helpers will load them from their original location (with the URI's pointing to your local sever).

    Note: these files can easily be generated with the sgLessPlugin