wijourdil / statically-cdn-helper
一个用于使用 statically.io CDN 的 Laravel/Lumen PHP 辅助工具
1.0.0
2022-03-02 16:04 UTC
Requires
- php: ^8.0
- ext-json: *
Requires (Dev)
- friendsofphp/php-cs-fixer: ^3.6
- orchestra/testbench: ^7.1
- phpstan/phpstan: ^1.4
- phpunit/phpunit: ^9.5
- squizlabs/php_codesniffer: ^3.6
README
⚡ Statically.io Laravel/Lumen 辅助工具
安装
composer require wijourdil/statically-cdn-helper
Laravel
无需操作,包将自动被发现。
Lumen
在您的 bootstrap/app.php
文件中注册包的服务提供者
$app->register(\Wijourdil\Statically\StaticallyCdnHelperServiceProvider::class);
配置
您可以在您的 .env
文件中定义以下常量
# What: (de)activate the cdn helper # Allowed value: true | false # Default: false CDN_ENABLED=true # What: define your website domain to use in generated cdn url # Allowed value: any string containing a valid domain # Default: env('APP_URL') CDN_SITE_DOMAIN="www.my-website.com"
用法
只需使用 cdn()
辅助工具代替 mix()
的 asset()
// Before asset('img/photo.png') // => 'https://site.com/img/photo.png' // After, without mix-manifest.json cdn('img/photo.png') // => '//cdn.statically.io/img/site.com/img/photo.png' // After, with mix-manifest.json cdn('img/photo.png') // => '//cdn.statically.io/img/site.com/img/photo.png?id=23ea1efe0290977b58d454f5164b2a32'