PHPackages                             elefant/app-cloudfront - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. elefant/app-cloudfront

ActiveElefant-app[Utility &amp; Helpers](/categories/utility)

elefant/app-cloudfront
======================

CloudFront app for the Elefant CMS

1.0(14y ago)214MIT

Since May 11Compare

[ Source](https://github.com/jbroadway/cloudfront)[ Packagist](https://packagist.org/packages/elefant/app-cloudfront)[ RSS](/packages/elefant-app-cloudfront/feed)WikiDiscussions Synced 2mo ago

READMEChangelogDependencies (1)Versions (2)Used By (0)

CloudFront
==========

[](#cloudfront)

This is a ridiculously simple app to help integrate an [Elefant](http://www.elefantcms.com/)website with the [Amazon CloudFront](http://aws.amazon.com/cloudfront/) content distribution network (CDN).

Setup
-----

[](#setup)

1\. Sign up for an [AWS account](http://aws.amazon.com/cloudfront/) and add CloudFront to your services in the AWS Management Console.

2\. Still in the AWS Management Console, go to CloudFront and click the `Create Distribution` button. Choose the following options in the Create Distribution Wizard:

- Delivery Method: `Download`
- Distribution Type: `Custom Origin`
- Origin DNS Name: `www.example.com`

> Be sure to change `www.example.com` to match your website's domain name.

You can find more information about the other settings [here](http://docs.amazonwebservices.com/AmazonCloudFront/latest/DeveloperGuide/CreatingDistributions.html). Now click Continue.

[![Create Distribution Wizard](https://camo.githubusercontent.com/334dc44cbf31850d9b6e67c6c58a26be8261d15b002aae7f78d428546e7536e8/687474703a2f2f646f63732e616d617a6f6e77656273657276696365732e636f6d2f416d617a6f6e436c6f756446726f6e742f6c61746573742f446576656c6f70657247756964652f696d616765732f437265617465446973747269627574696f6e57697a2e706e67)](https://camo.githubusercontent.com/334dc44cbf31850d9b6e67c6c58a26be8261d15b002aae7f78d428546e7536e8/687474703a2f2f646f63732e616d617a6f6e77656273657276696365732e636f6d2f416d617a6f6e436c6f756446726f6e742f6c61746573742f446576656c6f70657247756964652f696d616765732f437265617465446973747269627574696f6e57697a2e706e67)

3\. **Optional** Under Distribution Details, choose a subdomain like `cdn.example.com` and enter it into the CNAMEs field. We'll be pointing this CNAME to CloudFront in our DNS settings in a later step. For more info on the other settings, [click here](http://docs.amazonwebservices.com/AmazonCloudFront/latest/DeveloperGuide/CreatingDistributions.html).

[![Distribution Details](https://camo.githubusercontent.com/c6d7106efc5ec27216b582d600c5ea209dee4b265c155dd813ac1e9cc1df129c/687474703a2f2f646f63732e616d617a6f6e77656273657276696365732e636f6d2f416d617a6f6e436c6f756446726f6e742f6c61746573742f446576656c6f70657247756964652f696d616765732f437265617465446973747269627574696f6e57697a322e706e67)](https://camo.githubusercontent.com/c6d7106efc5ec27216b582d600c5ea209dee4b265c155dd813ac1e9cc1df129c/687474703a2f2f646f63732e616d617a6f6e77656273657276696365732e636f6d2f416d617a6f6e436c6f756446726f6e742f6c61746573742f446576656c6f70657247756964652f696d616765732f437265617465446973747269627574696f6e57697a322e706e67)

4\. **Optional** Once you've created your CloudFront distribution, copy the domain name shown in the Domain Name tab. Log into your registrar and add a CNAME to your DNS as follows:

```
Subdomain         Record Type   IP or Domain
cdn.example.com   CNAME         d604721fxaaqy9.cloudfront.net

```

5\. Copy the `cloudfront` app into your Elefant install's `apps` folder, then visit Extras &gt; CloudFront in the Elefant admin toolbar and enter the Amazon AWS CDN domain name (from step 3) into the `domain` field.

If you decided not to use a CNAME and skipped steps 3 and 4, simply copy the domain under the Domain Name tab for your newly created CloudFront distribution and use that instead.

Usage
-----

[](#usage)

In your views and layouts, any files you want to serve through CloudFront should be changed to look like this:

```

```

The file path is simply wrapped in `{! !}` tags (the single spaces are optional and are ignored), and the file path gets `cloudfront` added to it. This passes the file path to the CloudFront app's main handler to be rewritten as a CloudFront reference.

You can also call it directly via PHP like this:

```
