moneo / laravel-request-forwarder
Laravel Request Forwarder allows you to forward incoming requests to another addresses.
Fund package maintenance!
moneo
Requires
- php: ^8.1
- guzzlehttp/guzzle: ^7.8
- illuminate/contracts: ^10.0|^11.0
- spatie/laravel-package-tools: ^1.14.0
Requires (Dev)
- larastan/larastan: ^2.0.1
- laravel/pint: ^1.0
- nunomaduro/collision: ^7.8|^8.0
- orchestra/testbench: ^8.8|^9.0
- pestphp/pest: ^2.20
- pestphp/pest-plugin-arch: ^2.5
- pestphp/pest-plugin-laravel: ^2.0
- phpstan/extension-installer: ^1.1
- phpstan/phpstan-deprecation-rules: ^1.0
- phpstan/phpstan-phpunit: ^1.0
- spatie/laravel-ray: ^1.26
README
Laravel Request Forwarder
Sometimes we need to redirect requests to our application to other addresses. The best example of this is webhooks. Some service providers only send webhooks to a single address. With this package, you can post the requests coming to your application to another address as it is.
In addition to sending to a single URL, you can also send to different destinations by typing a custom provider. In our package you can see an example that sends notifications to Discord!
Installation
You can install the package via composer:
composer require moneo/laravel-request-forwarder
You can publish the config file with:
php artisan vendor:publish --tag="request-forwarder-config"
This is the contents of the published config file:
return [ // decides which webhook to use if no webhook group name is specified while use middleware 'default_webhook_group_name' => 'default', 'webhooks' => [ 'default' => [ 'targets' => [ [ 'url' => 'https://some-domain.com/webhook', 'method' => 'POST', ], [ 'url' => 'https://discord.com/api/webhooks/1209955556656291860/LAaczT-Pg785d5OzBmi6ivx2Vl7wAoruOwcVnZpb2eE2x8tf7fMi6R7_sr0IV0WoK83S', 'method' => 'POST', 'provider' => \Moneo\RequestForwarder\Providers\Discord::class, ], ], ], ], 'queue_name' => '', 'queue_class' => Moneo\RequestForwarder\ProcessRequestForwarder::class, ];
Usage
Add middleware to your routes which will be forwarded
Route::middleware('request-forwarder') // default group ->get('/endpoint', fn () => 'Some Response'); Route::middleware('request-forwarder:another-group-in-config') // customize targets with group name parameter ->get('/endpoint', fn () => 'Some Response');
Testing
composer test
Changelog
Please see CHANGELOG for more information on what has changed recently.
Contributing
Please see CONTRIBUTING for details.
Security Vulnerabilities
Please review our security policy on how to report security vulnerabilities.
Credits
License
The MIT License (MIT). Please see License File for more information.