Download the PHP package digitalcloud/laravel-forwarder without Composer
On this page you can find all versions of the php package digitalcloud/laravel-forwarder. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package laravel-forwarder
Laravel Forwarder.
This package allow you to forward the request from your project to another link. The forwarded request will be carry all original information.
This package is also give you the capability to get the response inside your code, and manipulate it before returning it as a final response.
Much more, you can also modify the request before sending it to the remote link as you need.
Installation
You can install the package via composer:
In Laravel 5.5 the service provider will automatically get registered. In older versions of the framework just add the service provider in config/app.php file:
After installation, you need to register the middleware "Forward" into your kernel in "routeMiddleware" array
How To Use
Now you can use new function on your route file as
This route function will make a request in background to the specified domain followed by the route
For example, the above sample will forward post request to "http://example.com/posts".
Note:
If you using api.php route file, the above sample will forward to "http://example.com/api/posts"
After the request handled, the package will pass the result as "response" property in the request to the function 'PostController@index', which you can handle, update, and return result
Before Request
Do you need to update the request before send?? it's very simple, just create a function on the same controller with prefix "before"
For example, if the function name on your controller is "index", you have to make another one with "beforeIndex" name and the package will take care of the remain
Note:
Note that any before function should return "Request" object so that can be passed to the remain chain.