mald/cdn-helper

Helper function to create CDN url's

dev-master 2023-03-23 11:18 UTC

This package is auto-updated.

Last update: 2024-04-23 14:00:19 UTC


README

CDN helper

Installation

  1. First install the helper with composer:

composer require mald/cdn-helper

  1. Publish assets:

php artisan vendor:publish --tag=mald-cdn-helper

Add CDN_URL to the .env of the project with the correct url towards the cdn, for example:

CDN_URL=https://d1pj9b3xsimjd0.cloudfront.net

Usage

Within our project you can use the cdn() helper function which accepts 3 parameters:

<?php

if (!function_exists('cdn')) {
    function cdn(string $path, ?string $dimensions = null, ?string $mode = 'crop'): string
    {
        return new \CdnHelper\Url($path, $dimensions, $mode);
    }
}

Testing

Run the tests with;

./vendor/bin/phpunit