PHPackages                             anothy/slim-api-wrapper - 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. [Framework](/categories/framework)
4. /
5. anothy/slim-api-wrapper

ActiveLibrary[Framework](/categories/framework)

anothy/slim-api-wrapper
=======================

Slim Api Wrapper

0.1.4(8y ago)021MITPHP

Since Aug 4Pushed 8y ago1 watchersCompare

[ Source](https://github.com/anothy/slim-api-wrapper)[ Packagist](https://packagist.org/packages/anothy/slim-api-wrapper)[ RSS](/packages/anothy-slim-api-wrapper/feed)WikiDiscussions master Synced yesterday

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

Slim Api Wrapper
================

[](#slim-api-wrapper)

Used as a way of accessing Slim App APIs internally. There are two types of accessing the APIs, directly where it skips the traversal of middleware(s), or using the full route where it traverses the middleware(s) attached to the Slim app.

### Installation

[](#installation)

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

```
$ composer require anothy/slim-api-wrapper
```

### Usage

[](#usage)

Setup container:

```
$container['slim-api-wrapper'] = function (\Slim\Container $c) {
    return new \Anothy\SlimApiWrapper($c);
};
```

#### Calling a named-route using the `call` method.

[](#calling-a-named-route-using-the-call-method)

The `call` method will skip the traversal of the middleware (in and out) and go straight to the Slim application.

```
$app = new \Slim\App();

$app->get('/books', function ($request, $response, $args) {
    // Show all books
})->setName('api-books');

$slimApiWrapper = $app->getContainer()->get('slim-api-wrapper');

$result = $slimApiWrapper->call('GET', 'api-books', [
   'queryParams' => [
       'page' => 1,
   ],
]);
```

The above example would look for the named-route `api-books` with `GET` method and with QueryString of `page=1`.

#### Calling a named-route using the `callMiddlewareStack` method.

[](#calling-a-named-route-using-the-callmiddlewarestack-method)

The `callMiddlewareStack` method will traverse middleware(s) (in and out) added to the Slim application.

```
$result = $slimApiWrapper->callMiddlewareStack('GET', 'api-books', [
    'queryParams' => [
        'page' => 1,
    ],
]);
```

#### Adding route pattern placeholders

[](#adding-route-pattern-placeholders)

If your route has any pattern placeholders, you can add the `namedArgs` to the call.

```
$app->get('/books/{id:[0-9]+}', function ($request, $response, $args) {
    // Show all books by `id`
})->setName('api-books-by-id');

$result = $slimApiWrapper->call('GET', 'api-books-by-id', [
    'namedArgs' => [
        'id' => 1234,
    ],
]);
```

The above call is equivalent to doing a `GET /books/1234`.

#### Adding additional headers

[](#adding-additional-headers)

Here is an example with the named-route `api-books` that require an Authorization header. A `headers` option is added with the `HTTP_AUTHORIZATION` key and value. The value is for an OAuth token.

```
$result = $slimApiWrapper->call('GET', 'api-books', [
    'headers' => [
        'HTTP_AUTHORIZATION' => 'Bearer ' . $token,
    ],
    'queryParams' => [
        'page' => 1,
    ],
]);
```

#### Adding a payload (body) to a request

[](#adding-a-payload-body-to-a-request)

```
$result = $slimApiWrapper->call('POST', 'api-books-post', [
    'headers' => [
        'HTTP_AUTHORIZATION' => 'Bearer ' . $token,
    ],
    'payload' => [
        'name'   => 'The Name of the Wind',
        'author' => 'Patrick Rothfuss',
    ],
]);
```

This adds `payload` to the request body as a JSON string.

###  Health Score

25

—

LowBetter than 36% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity6

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity57

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 ~3 days

Total

4

Last Release

3243d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/1765969?v=4)[Anthony D](/maintainers/anothy)[@anothy](https://github.com/anothy)

---

Top Contributors

[![anothy](https://avatars.githubusercontent.com/u/1765969?v=4)](https://github.com/anothy "anothy (10 commits)")

---

Tags

apiframeworkslim

###  Code Quality

TestsPHPUnit

Code StylePHP\_CodeSniffer

### Embed Badge

![Health badge](/badges/anothy-slim-api-wrapper/health.svg)

```
[![Health](https://phpackages.com/badges/anothy-slim-api-wrapper/health.svg)](https://phpackages.com/packages/anothy-slim-api-wrapper)
```

###  Alternatives

[slim/twig-view

Slim Framework 4 view helper built on top of the Twig 3 templating component

3738.4M230](/packages/slim-twig-view)[gotzmann/comet

Modern PHP framework for building blazing fast REST APIs and microservices

68316.2k1](/packages/gotzmann-comet)[patricksavalle/slim-rest-api

Production-grade REST-API App-class for PHP SLIM, in production on https://zaplog.pro (https://api.zaplog.pro/v1)

101.4k](/packages/patricksavalle-slim-rest-api)

PHPackages © 2026

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