• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Public variable

#1
Codeigniter 3 I had in /config/config.php:

$config['cdn_url']  = 'https://domain.com/';

But Codeigniter 4 it does not work this way:

public $cdn_url  = 'https://domain.com/';
Reply

#2
You can still use configuration files very much the same way that CI3 used to do them... Check out the user guide if you haven't already: https://codeigniter4.github.io/CodeIgnit...ation.html
It probably mostly comes down to what you want to be doing with that variable.
Reply

#3
Anyway, the goal is to do this below for Codeigniter 4. It's hard. Can anyone help?

https://www.keycdn.com/support/codeignit...ntegration
Reply

#4
That's a whole lot of work for a relatively simple result. If you are using an application that already includes all its assets using `base_url()` then it might save a little time by extending the URL Helper to override `base_url()`... but if you are writing new, or don't have that many calls to `base_url()` I'd recommend just doing this yourself. You could make a simple keycdn helper:
PHP Code:
if (! function_exists('keycdn'))
{
    function 
keycdn(string $uri ''): string
    
{
        return 
'https://examplepull-1a2b.kxcdn.com/' $uri;
    }


Then in your view just call that instead of `base_url()` anytime you want to use a CDN asset: `<?= keycdn('styles.css') ?>`
Reply

#5
It worked.. Thank you for the help. Smile
Reply

#6
(03-22-2019, 01:01 PM)edica Wrote: Anyway, the goal is to do this below for Codeigniter 4. It's hard. Can anyone help?

https://www.keycdn.com/support/codeignit...ntegration
you can call your config:
echo Config('ConfigName')->property
for example
echo Config('App')->cdn_url
Reply


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


Users browsing this thread:
1 Guest(s)


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2019 MyBB Group.