December 2017
Beginner to intermediate
376 pages
7h 53m
English
The cdn helper method will need to know the URL of the CDN. Let's set an CDN_URL environment variable that will be assigned the zone URL for Vuebnb, minus the protocol prefix.
While we're at it, let's add another variable, CDN_BYPASS, that can be used to bypass the CDN in our local development environment where we won't need it.
.env:
... CDN_URL=vuebnb-9c0f.kxcdn.com CDN_BYPASS=0
Let's now register these new variables in the app configuration file.
config/app.php:
<?php
return [
...
// CDN
'cdn' => [
'url' => env('CDN_URL'),
'bypass' => env('CDN_BYPASS', false),
],
];
Now we can complete the logic of our cdn helper.
app/helpers.php:
<?php use Illuminate\Support\Facades\Config; if (!function_exists('cdn')) { function cdn($asset) ...Read now
Unlock full access