takethelead / laravel-storyblok-file-proxy
File proxy for Storyblok
Installs: 1 219
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 0
Open Issues: 2
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-11-06 17:24:00 UTC
README
Convert Storyblok file urls to local urls and proxy them through your Laravel application. You can easily add extra middlewares to the proxy route, for example to add extra authorization checks.
Installation
You can install the package via composer:
composer require takethelead/laravel-storyblok-file-proxy
You can publish the config file with:
php artisan vendor:publish --provider="TakeTheLead\LaravelStoryblokFileProxy\LaravelStoryblokFileProxyServiceProvider" --tag="config"
This is the contents of the published config file:
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', ], ], ];
Usage
Proxy route
The package will proxy files through the application, therefore it registers a route in the application. You can define a custom base slug in the config file, this way you can prevent collision with your existing routes.
Through the config file you can also specify the route middleware (groups) that should be applied to the route.
Convert Storyblok urls to local urls
\StoryblokUrl::toLocal($file['filename']);
Testing
composer test
Changelog
Please see CHANGELOG for more information on what has changed recently.
Contributing
Please see CONTRIBUTING for details.
Security
If you discover any security related issues, please email info@takethelead.be instead of using the issue tracker.
Credits
License
The MIT License (MIT). Please see License File for more information.