CodeIgniter Forums
Integrating cloudways CDN to my Codeigniter project - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5)
+--- Forum: General Help (https://forum.codeigniter.com/forumdisplay.php?fid=24)
+--- Thread: Integrating cloudways CDN to my Codeigniter project (/showthread.php?tid=78008)



Integrating cloudways CDN to my Codeigniter project - EseMiami - 11-19-2020

I have set up CDN on Cloudways and was given a CDN Url. This I understand I need to add to my web application built on CodeIgniter.
[font=Arial,]I tried what solutions I could find on the web but it's either I'm not doing it right or it simply does not work.[/font]

[font=Arial,]I created a new helper file (cdn_helper.php) in my controller folder
[/font]


PHP Code:
function cdn_base_url($uri)
 
{
   $currentInstance =& get_instance();
   $keybasedcdnUrl $currentInstance->config->item('cdn_based_key_url');
   $extensions = array('css''js''jpg''jpeg''png''gif','pdf');
   $pathParts pathinfo($uri);
 
   if (!empty($keybasedcdnUrl) && in_array($pathParts['extension'],$extensions)) {
       return $keybasedcdnUrl $uri;
   }

   return $currentInstance->config->cdn_base_url($uri);



Then I added this line to my config file


PHP Code:
$config['cdn_based_key_url'] = 'https://457224-1431795-raikfcquaxqncofqfm.stackpathdns.com/'

It didn't work. However, I read something about setting my own prefix to extend the URL helper
PHP Code:
$config['subclass_prefix'] = 'MY_'
 
when I change the prefix to something like this 'ext.'; it gives an error.
please how do I properly integrate CDN?