takethelead / laravel-storyblok-file-proxy
Storyblok 文件代理
1.3.0
2023-10-02 15:43 UTC
Requires
- php: ^8.1|^8.2
- ext-fileinfo: *
- guzzlehttp/guzzle: ^7.0
- illuminate/container: ^9.0|^10.0
- illuminate/http: ^9.0|^10.0
- illuminate/routing: ^9.0|^10.0
- illuminate/support: ^9.0|^10.0
Requires (Dev)
- friendsofphp/php-cs-fixer: ^3.10
- orchestra/testbench: ^7.0|^8.0
- phpunit/phpunit: ^9.0
- psalm/plugin-laravel: ^1.2|^2.0
- vimeo/psalm: ^3.11|^4.0
This package is auto-updated.
Last update: 2024-08-31 00:25:56 UTC
README
将 Storyblok 文件 URL 转换为本地 URL 并通过您的 Laravel 应用程序代理。您可以在代理路由中轻松添加额外的中间件,例如添加额外的授权检查。
安装
您可以通过 composer 安装此包
composer require takethelead/laravel-storyblok-file-proxy
您可以使用以下命令发布配置文件
php artisan vendor:publish --provider="TakeTheLead\LaravelStoryblokFileProxy\LaravelStoryblokFileProxyServiceProvider" --tag="config"
这是已发布配置文件的内容
return [ /* |-------------------------------------------------------------------------- | Base url |-------------------------------------------------------------------------- | | Define the base url to proxy files through. | | Ex. 'files' will result in https://appurl.test/files/{fileSlug} | */ 'base_url' => 'files', /* |-------------------------------------------------------------------------- | Middleware |-------------------------------------------------------------------------- | | Define the route middleware (groups) where the proxy route should be | wrapped in. | | */ 'middleware' => [ 'web', ], /* |-------------------------------------------------------------------------- | Proxy urls |-------------------------------------------------------------------------- | | Define all url types that should be formatted. Each proxy should | have at least a "type" and "url" property. The defined base url | will be swapped with a local url. | */ 'proxy_urls' => [ [ 'type' => 'images', 'url' => 'https://img2.storyblok.com', ], [ 'type' => 'other', 'url' => 'https://a.storyblok.com', ], ], ];
使用方法
代理路由
该包将通过应用程序代理文件,因此它会在应用程序中注册一个路由。您可以在配置文件中定义自定义的基础路径,这样您可以防止与现有路由发生冲突。
您也可以通过配置文件指定应用于路由的路由中间件(组)。
将 Storyblok URL 转换为本地 URL
\StoryblokUrl::toLocal($file['filename']);
测试
composer test
变更日志
请参阅 CHANGELOG 了解最近更改的详细信息。
贡献
请参阅 CONTRIBUTING 了解详细信息。
安全
如果您发现任何与安全相关的问题,请通过电子邮件 info@takethelead.be 联系我们,而不是使用问题跟踪器。
鸣谢
许可证
MIT 许可证(MIT)。请参阅 许可证文件 了解更多信息。