PHP code example of thezombieguy / laravel-internal-request
1. Go to this page and download the library: Download thezombieguy/laravel-internal-request library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
thezombieguy / laravel-internal-request example snippets
use TheZombieGuy\InternalRequest\Services\InternalRequestService;
$service = app(InternalRequestService::class);
use TheZombieGuy\InternalRequest\Services\InternalRequestService;
$service = app(InternalRequestService::class);
$urlParams = ['id' => 123];
$queryParams = ['foo' => 'bar'];
$headers = ['x-test-header' => 'something fun'];
$response = $service->request(
'test.route',
'GET',
$urlParams,
$queryParams,
$headers,
$bodyParams, // for post put or update methods
);
class AppServiceProvider extends ServiceProvider
{
public function register()
{
// Bind the service and add the default afterRequest hook
$this->app->bind(InternalRequestService::class, function () {
$service = new InternalRequestService();
// Define the default afterRequest closure
$originalRequest = \request();
$service->setAfterRequest(static function () use (&$originalRequest) {
// Reset the request back to its original state
App::instance('request', $originalRequest);
});
return $service;
});
}
}
use TheZombieGuy\InternalRequest\Services\InternalRequestService;
$service = \app(InternalRequestService::class);
$response = $service->request('your.route');
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.