Skip to main content

Phalcon Medianova CDN Integration

Phalcon is a high-performance PHP framework that is open source and available to developers with MVC logic. Unlike many PHP skeletons on the market, it is written as an extension to PHP with C.

In this document, we have described alternative ways to integrate between Phalcon and Medianova CDN.

Note: We recommend back up your files and database before they integrate.

  1. First, create the Zone for account.

  2. We recommend the first option to make the integration; define setStaticBaseUri.

CODE
<?php

$url = new Phalcon\Mvc\Url();

// Dynamic URIs remain on your origin server
$url->setBaseUri('/');

// Static resources go through MedianovaCDN
$url->setStaticBaseUri('http://your-origin-url.com/');
  1. As an alternative to this path, use the collections and add a URL-prefix for CDN URL

CODE
<?php

$css = $this->assets->collection('header');
$scripts = $this->assets->collection('footer');

if ($config->environment == 'development') {
    $css->setPrefix('/');
    $scripts->setPrefix('/');
} else {
    $cdnURL = 'http://your-cdn-url.com/';
    $css->setPrefix($cdnURL);
    $scripts->setPrefix($cdnURL);
}

$css->addCss('css/bootstrap.min.css')
        ->addCss('js/custom.css');

$scripts->addJs('js/jquery.js')
        ->addJs('js/bootstrap.min.js');
  1. The last alternative offered

CODE
...
$cdnURL = 'http://your-cdn-url.com/';
$this->assets
     ->addCss($cdnURL.'css/custom.css', false);
...
  1. Check your HTML source code learn whether (or not) load your assets from Medianova CDN.

JavaScript errors detected

Please note, these errors can depend on your browser setup.

If this problem persists, please contact our support.