mald/cdn-helper

创建 CDN URL 的辅助函数

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

This package is auto-updated.

Last update: 2024-09-23 15:05:20 UTC


README

CDN 辅助工具

安装

  1. 首先使用 composer 安装辅助工具

composer require mald/cdn-helper

  1. 发布资产

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

将 CDN_URL 添加到项目的 .env 文件中,并指定正确的 CDN URL,例如

CDN_URL=https://d1pj9b3xsimjd0.cloudfront.net

使用方法

在我们的项目中,您可以使用接受 3 个参数的 cdn() 辅助函数

<?php

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

测试

运行测试:

./vendor/bin/phpunit