PHPackages                             thezombieguy/laravel-internal-request - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [HTTP &amp; Networking](/categories/http)
4. /
5. thezombieguy/laravel-internal-request

ActiveLibrary[HTTP &amp; Networking](/categories/http)

thezombieguy/laravel-internal-request
=====================================

A Laravel package to handle internal route requests

v1.1.2(1y ago)13.0k↓77.8%MITPHPPHP ^8.1

Since Oct 4Pushed 1y ago1 watchersCompare

[ Source](https://github.com/thezombieguy/laravel-internal-request)[ Packagist](https://packagist.org/packages/thezombieguy/laravel-internal-request)[ RSS](/packages/thezombieguy-laravel-internal-request/feed)WikiDiscussions main Synced 2d ago

READMEChangelog (4)Dependencies (12)Versions (6)Used By (0)

Laravel Internal Request
========================

[](#laravel-internal-request)

**Easily request data from internal routes within your Laravel application without making external HTTP calls.**

[![Tests](https://github.com/thezombieguy/laravel-internal-request/actions/workflows/ci.yml/badge.svg)](https://github.com/thezombieguy/laravel-internal-request/actions/workflows/ci.yml/badge.svg)[![PHP Version](https://camo.githubusercontent.com/cc9cdea9aa96b40a822425e981b0a030e3371202973c7d57b74e8e99834f81dc/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f7068702d253545382e312d626c7565)](https://camo.githubusercontent.com/cc9cdea9aa96b40a822425e981b0a030e3371202973c7d57b74e8e99834f81dc/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f7068702d253545382e312d626c7565)[![License](https://camo.githubusercontent.com/f8df3091bbe1149f398a5369b2c39e896766f9f6efba3477c63e9b4aa940ef14/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d677265656e)](https://camo.githubusercontent.com/f8df3091bbe1149f398a5369b2c39e896766f9f6efba3477c63e9b4aa940ef14/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d677265656e)[![Downloads](https://camo.githubusercontent.com/de5722088b17b5d61e733239ba07d04fc0738be0026c0c82124829c6debce451/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f7468657a6f6d6269656775792f6c61726176656c2d696e7465726e616c2d72657175657374)](https://camo.githubusercontent.com/de5722088b17b5d61e733239ba07d04fc0738be0026c0c82124829c6debce451/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f7468657a6f6d6269656775792f6c61726176656c2d696e7465726e616c2d72657175657374)

Sometimes, it's easier and more efficient to request data from an existing internal route rather than making an external HTTP call back to your application. This package provides a clean and simple interface to make internal route requests, saving overhead and improving performance.

Requirements
------------

[](#requirements)

- PHP &gt;= 8.1
- Laravel 10.x or 11.x

Installation
------------

[](#installation)

You can install this package via Composer. It's recommended for scenarios where you want to avoid external HTTP calls and instead make requests to your own application internally.

```
composer require thezombieguy/laravel-internal-request
```

Usage
-----

[](#usage)

To use the internal request service, resolve it from the Laravel service container:

```
use TheZombieGuy\InternalRequest\Services\InternalRequestService;

$service = app(InternalRequestService::class);
```

To call an internal route, use the $service-&gt;request() method:

```
$response = $service->request('valid.route.name');
```

By default, the service will send a get request to the internal route and return a standard response, similar to an external HTTP call.

Passing Parameters
------------------

[](#passing-parameters)

You can also pass HTTP methods, query parameters, URL parameters, and additional headers. Let's assume you have a route called `test.route` with the URL structure `/test/{id}`:

```
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
);
```

This will call the route `/test/123` with the url params and headers.

Hooking Into the Request Lifecycle
----------------------------------

[](#hooking-into-the-request-lifecycle)

You can hook into the request lifecycle to execute custom logic before or after the internal request is made. This is useful when calling the internal route from services like Livewire, where you may need to avoid altering the original request object.

### Example: Resetting Request State

[](#example-resetting-request-state)

In your `AppServiceProvider`, you can bind the `afterRequest` callback to restore the original request object after making an internal request:

```
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;
        });
    }
}
```

And then just call your service in the code wherever you require.

```
use TheZombieGuy\InternalRequest\Services\InternalRequestService;

$service = \app(InternalRequestService::class);
$response = $service->request('your.route');
```

The `setAfterRequest()` hook will restore the original request after the internal request has been completed. You can also use `setBeforeRequest()` to define logic that should execute before the internal request.

### Lifecycle Events

[](#lifecycle-events)

When executing the before and after request hooks, the service will dispatch the following events:

- internal\_request.before
- internal\_request.after

You can listen to these events in your application to execute custom logic before or after the internal request is made.

```
## License

This package is open-source software licensed under the [MIT License](LICENSE.md).
```

###  Health Score

33

—

LowBetter than 72% of packages

Maintenance37

Infrequent updates — may be unmaintained

Popularity22

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity52

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 54.5% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~23 days

Total

4

Last Release

567d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/3126f8099d7c7e2c480641ca6831adee39b8d7638892e43da7f3cb61976ed798?d=identicon)[thezombieguy](/maintainers/thezombieguy)

---

Top Contributors

[![thezombieguy](https://avatars.githubusercontent.com/u/2289984?v=4)](https://github.com/thezombieguy "thezombieguy (18 commits)")[![primebevil](https://avatars.githubusercontent.com/u/299011842?v=4)](https://github.com/primebevil "primebevil (15 commits)")

---

Tags

requestlaravelrouteinternalinternal route

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StylePHP CS Fixer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/thezombieguy-laravel-internal-request/health.svg)

```
[![Health](https://phpackages.com/badges/thezombieguy-laravel-internal-request/health.svg)](https://phpackages.com/packages/thezombieguy-laravel-internal-request)
```

###  Alternatives

[psalm/plugin-laravel

Psalm plugin for Laravel

3355.3M346](/packages/psalm-plugin-laravel)[api-platform/laravel

API Platform support for Laravel

58171.6k14](/packages/api-platform-laravel)[laravel/mcp

Rapidly build MCP servers for your Laravel applications.

77022.3M151](/packages/laravel-mcp)[laravel/cashier

Laravel Cashier provides an expressive, fluent interface to Stripe's subscription billing services.

2.6k29.9M146](/packages/laravel-cashier)[laravel/pulse

Laravel Pulse is a real-time application performance monitoring tool and dashboard for your Laravel application.

1.7k15.1M132](/packages/laravel-pulse)[roots/acorn

Framework for Roots WordPress projects built with Laravel components.

9762.4M131](/packages/roots-acorn)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
