PHPackages                             wronx/lumen-rest-object-fetch-middleware - 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. wronx/lumen-rest-object-fetch-middleware

ActiveLumen-package[HTTP &amp; Networking](/categories/http)

wronx/lumen-rest-object-fetch-middleware
========================================

Simple Lumen middleware for simple fetching simple objects in simple REST API endpoints

v0.1.1(7y ago)01.1k1WTFPLPHPPHP &gt;=7.1

Since Jul 19Pushed 7y ago1 watchersCompare

[ Source](https://github.com/WRonX/Lumen-RestObjectFetch-middleware)[ Packagist](https://packagist.org/packages/wronx/lumen-rest-object-fetch-middleware)[ RSS](/packages/wronx-lumen-rest-object-fetch-middleware/feed)WikiDiscussions master Synced yesterday

READMEChangelog (2)Dependencies (3)Versions (3)Used By (1)

Lumen REST Object Fetch Middleware
----------------------------------

[](#lumen-rest-object-fetch-middleware)

> **IMPORTANT:** This package is a work in progress, it it not stable by any means.
> Use responsibly! Or don't use at all and wait for v1.0.

#### The purpose of this project

[](#the-purpose-of-this-project)

It was created to avoid repetitive 404 (and other) checks when hitting CRUD endpoints of API.

#### Is it any good?

[](#is-it-any-good)

[Yes](https://news.ycombinator.com/item?id=3067434)

(well, it will be in stable version... I hope...)

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

[](#installation)

1. Install the package with [Composer](https://getcomposer.org/):

```
composer require wronx/lumen-rest-object-fetch-middleware
```

2. Enable it in `bootstrap/app.php`:

```
$app->routeMiddleware([
// ...
                          'object' => WRonX\RestObjectFetch\RestObjectFetchMiddleware::class,
                      ]);
```

Usage
-----

[](#usage)

1. In `routes/web.php` assign it to route which requires `id` parameter, giving it model's class name:

```
$router->group([
                   'prefix'     => '/something/{id:[0-9]+}',
                   'middleware' => 'object:Something', // get('', [
            'as'   => 'show_something',
            'uses' => 'SomethingController@show',
        ]);

        $router->patch('', [
            'as'   => 'edit_something',
            'uses' => 'SomethingController@update',
        ]);

        $router->delete('', [
            'as'   => 'delete_something',
            'uses' => 'SomethingController@destroy',
        ]);
    });
```

2. In Controller methods that are covered by this middleware you don't have to check if object exists and you don't have to fetch it again from DB:

```
    public function show(Request $request) {
        $something = $request->attributes->get('fetchedObject');

        return new JsonResponse($something);
    }
```

Contributing
------------

[](#contributing)

If you want to contribute, **please wait**. Until stable version arrives I want to shape this package in my specific way. Later on, pull requests will be welcome.

License:
--------

[](#license)

> Copyright © 2016 github.com/WRonX
> This work is free. You can redistribute it and/or modify it under the terms of the Do What The Fuck You Want To Public License, Version 2, as published by Sam Hocevar. See  for more details

###  Health Score

25

—

LowBetter than 36% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity14

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity49

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% 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 ~87 days

Total

2

Last Release

2815d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/2788306?v=4)[WRonX](/maintainers/WRonX)[@WRonX](https://github.com/WRonX)

---

Top Contributors

[![WRonX](https://avatars.githubusercontent.com/u/2788306?v=4)](https://github.com/WRonX "WRonX (3 commits)")

---

Tags

middlewarerestlumen

### Embed Badge

![Health badge](/badges/wronx-lumen-rest-object-fetch-middleware/health.svg)

```
[![Health](https://phpackages.com/badges/wronx-lumen-rest-object-fetch-middleware/health.svg)](https://phpackages.com/packages/wronx-lumen-rest-object-fetch-middleware)
```

###  Alternatives

[api-platform/core

Build a fully-featured hypermedia or GraphQL API in minutes!

2.6k50.1M314](/packages/api-platform-core)[psalm/plugin-laravel

Psalm plugin for Laravel

3345.1M337](/packages/psalm-plugin-laravel)[illuminate/routing

The Illuminate Routing package.

1239.0M2.9k](/packages/illuminate-routing)[illuminate/http

The Illuminate Http package.

11937.2M6.6k](/packages/illuminate-http)[api-platform/laravel

API Platform support for Laravel

59156.3k11](/packages/api-platform-laravel)[api-platform/validator

API Platform validator component

274.1M23](/packages/api-platform-validator)

PHPackages © 2026

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