2017 © Pedro Peláez
 

silverstripe-module ss-easy-s3

Seamlessly integrates assets (including themes folder) along with css and js. Enabling CloudFront is simply a config change.

image

fspringveldt/ss-easy-s3

Seamlessly integrates assets (including themes folder) along with css and js. Enabling CloudFront is simply a config change.

  • Thursday, March 15, 2018
  • by fspringveldt
  • Repository
  • 2 Watchers
  • 5 Stars
  • 31 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 3 Forks
  • 1 Open issues
  • 2 Versions
  • 0 % Grown

The README.md

Amazon S3 bucket integration

Seamlessly integrates assets,theme assets, css and js with S3 - with optional CloudFront CDN., (*1)

Minimum requirements

silverstripe/framework: ^3.5.*
silverstripe/cms: ^3.5.*
aws/aws-sdk-php: ^3.18

Installation and Setup

To install, run below from root of SilverStripe installation, (*2)

> composer require fspringveldt/ss-easy-s3

http://your-site-url?flush=1 once composer is complete the flush the manifest., (*3)

Once installed and configured, head on over to Amazon, create an account and bucket. Below are some resources you can use to assist during this process., (*4)

Once your Amazon info is sorted, you'll need the following info from the Amazon console:, (*5)

  • key
  • secret
  • region
  • bucket
  • url
  • distribution-id

...which is then input into your mysite the config file as:, (*6)

S3Facade:
  config:
    dev:
      key:
      secret:
      region:
      bucket:
      url:
      distribution-id:
    test:
      key:
      secret:
      region:
      bucket:
      url:
      distribution-id:
    live:
      key:
      secret:
      region:
      bucket:
      url:
      distribution-id:

NB: You can setup multiple configs per environment . A simple flush should complete your setup., (*7)

This module will automagically re-write all your URL's to point to the resources from either the S3 Bucket or CloudFront url you specified., (*8)

Deleting local files

You now also have the option to delete local files and only keep those in S3, which is switched off by default. To enable this functionality, do the following: 1. Add this config entry, (*9)

Image:
    keepLocal: false
  1. Then schedule the task called RemoveLocalCopies to run at a comfortable interval to remove these files. An example cron entry reflects below, replacing everything in square brackets with correct values
*/5 * * * * [path-to-php-binary] [path-to-application]/framework/cli-script.php dev/build

An example on ubuntu: */5 * * * * /usr/bin/php /var/www/example/framework/cli-script.php dev/build, (*10)

Migrate to S3 build-task

There is also a handy tool which will upload entire directories to your S3 bucket blisteringly fast. You can specify which directories to upload via the _ config/config.yml file by adding more entries to the migrationFolders property. The assets folder is added by default., (*11)

Working with local environment

  1. Download certificate file
  2. Copy it inside ss-easy-s3/ root directory (assuming ss-easy-s3 folder is inside project root directory)
  3. Add some additional config below inside the config array() in setupS3Client() and setupCloudFrontClient() method in code/classes/S3Facade.php file, (*12)

    $array = array(
        'version' => ...,
        'region' => ...,
        'credentials' => ...,
        // add these lines
        'scheme'  => 'http',
        'http'    => [
            'verify' => '../ss-easy-s3/cacert.pem'
        ]
    );
  4. Refresh the page and test uploading image (in my case using Files page in CMS Admin), (*13)

*Note: You should disable all debug command such as Debug::show and var_dump(), (*14)

References: - AWS SSL security error : [curl] 60: blablabla - Config to disable SSL - Pinging your S3 Bucket Service, (*15)

The Versions

15/03 2018

dev-master

9999999-dev https://github.com/fspringveldt/ss-easy-s3

Seamlessly integrates assets (including themes folder) along with css and js. Enabling CloudFront is simply a config change.

  Sources   Download

The Requires

 

The Development Requires

by Franco Springveldt

silverstripe s3-integration amazon-s3 ss-easy-s3

15/03 2018

dev-feature/psr2

dev-feature/psr2 https://github.com/fspringveldt/ss-easy-s3

Seamlessly integrates assets (including themes folder) along with css and js. Enabling CloudFront is simply a config change.

  Sources   Download

The Requires

 

The Development Requires

by Franco Springveldt

silverstripe s3-integration amazon-s3 ss-easy-s3