xlabs/cdnbundle

CDN bundle

Installs: 140

Dependents: 1

Suggesters: 0

Security: 0

Type:symfony-bundle

1.0.9 2022-11-18 15:54 UTC

This package is auto-updated.

Last update: 2022-11-18 15:54:47 UTC


README

CDN wrapper engine.

Installation

Install through composer:

php -d memory_limit=-1 composer.phar require xlabs/cdnbundle

In your AppKernel

public function registerbundles()
{
    return [
    	...
    	...
    	new XLabs\CDNBundle\XLabsCDNBundle(),
    ];
}

Configuration sample

Default values are shown below:

# app/config/config.yml

x_labs_cdn:
    providers:
        highwinds:
            account: ############
            api_username: ############
            api_password: ############
            zones:
                sample_public: {url: 'https://cdn.static.yourdomain.ext'}
                sample_private: {url: 'https://cdn.yourdomain.ext', secretKey: '############', expiration_ttl: 7200}
                sample_download: {url: 'https://cdn-file.yourdomain.ext', secretKey: '############', expiration_ttl: 7200}
                ...
            default_zone: 'sample_public'
            path_renaming: # optional
                - { source: '^/my/path/', dest: '/cdn/rewrite/rule/path/'}
                - { source: '...', dest: '...'}
        provider2:
            param1: #######
            param2: #######
            ...
            paramN: #######
        ...

Usage

Instantiate the service from a Controller by:

$this->get('xlabs_cdn')->...

Usage (TWIG)

Instantiate the service from a twig template by:

{{ getCDNResource({
    'media_path' => '/path/to/my/asset.ext',
    'zone' => false, // default_zone will be used if unset
    'expiration_ttl' => 7200 // default ttl (7200) will be used if unset
}) }}