PHPackages                             subjective-php/slim-options-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. subjective-php/slim-options-middleware

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

subjective-php/slim-options-middleware
======================================

Middleware to add an OPTIONS route to routes.

022PHP

Since Apr 22Pushed 7y agoCompare

[ Source](https://github.com/subjective-php/slim-options-middleware)[ Packagist](https://packagist.org/packages/subjective-php/slim-options-middleware)[ RSS](/packages/subjective-php-slim-options-middleware/feed)WikiDiscussions master Synced 6d ago

READMEChangelogDependenciesVersions (1)Used By (0)

Slim OPTIONS Middleware
=======================

[](#slim-options-middleware)

Middleware to add an OPTIONS route to existing routes.

[![Build Status](https://camo.githubusercontent.com/7e1d26c0ddc9fb3878e14df66583d3e6dc099953a7f2e2865c7cc69c19cee8d2/68747470733a2f2f7472617669732d63692e636f6d2f7375626a6563746976652d7068702f736c696d2d6f7074696f6e732d6d6964646c65776172652e7376673f6272616e63683d6d6173746572)](https://travis-ci.com/subjective-php/slim-options-middleware)[![Scrutinizer Code Quality](https://camo.githubusercontent.com/a454dd5d2074c89e5c52d42a085d97f0112b8c166e4e060f8bdcaa9dc1a870bf/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f7375626a6563746976652d7068702f736c696d2d6f7074696f6e732d6d6964646c65776172652f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/subjective-php/slim-options-middleware/?branch=master)[![Coverage Status](https://camo.githubusercontent.com/91a2396a4fabea55186cf10f478388de996ebb15af5e8dbcaf2036aaf0314f2b/68747470733a2f2f636f766572616c6c732e696f2f7265706f732f6769746875622f7375626a6563746976652d7068702f736c696d2d6f7074696f6e732d6d6964646c65776172652f62616467652e7376673f6272616e63683d6d6173746572)](https://coveralls.io/github/subjective-php/slim-options-middleware?branch=master)

[![Latest Stable Version](https://camo.githubusercontent.com/db7b9c55b049805f7401a01c0ee4928d580731dd199ae1bc628a4a43499ce498/68747470733a2f2f706f7365722e707567782e6f72672f7375626a6563746976652d7068702f736c696d2d6f7074696f6e732d6d6964646c65776172652f762f737461626c65)](https://packagist.org/packages/subjective-php/slim-options-middleware)[![Latest Unstable Version](https://camo.githubusercontent.com/5ecb38fc76a4ec80e0103b951da71a4b8f8145ef3fa319ea3b0d55c3a5732999/68747470733a2f2f706f7365722e707567782e6f72672f7375626a6563746976652d7068702f736c696d2d6f7074696f6e732d6d6964646c65776172652f762f756e737461626c65)](https://packagist.org/packages/subjective-php/slim-options-middleware)[![License](https://camo.githubusercontent.com/08c8bad392f402963be6cdfd18a2f0a82dc0b2eb47c2757ac0740c27437bd703/68747470733a2f2f706f7365722e707567782e6f72672f7375626a6563746976652d7068702f736c696d2d6f7074696f6e732d6d6964646c65776172652f6c6963656e7365)](https://packagist.org/packages/subjective-php/slim-options-middleware)

[![Total Downloads](https://camo.githubusercontent.com/38f09567cf906eb9e76ef29164abc382dc13bcdd1c26a18963ccc3aab507a855/68747470733a2f2f706f7365722e707567782e6f72672f7375626a6563746976652d7068702f736c696d2d6f7074696f6e732d6d6964646c65776172652f646f776e6c6f616473)](https://packagist.org/packages/subjective-php/slim-options-middleware)[![Daily Downloads](https://camo.githubusercontent.com/a4c5b6eae5cc8946ba48c16e693bd94191f451d155845b62ac37aabb580eb723/68747470733a2f2f706f7365722e707567782e6f72672f7375626a6563746976652d7068702f736c696d2d6f7074696f6e732d6d6964646c65776172652f642f6461696c79)](https://packagist.org/packages/subjective-php/slim-options-middleware)[![Monthly Downloads](https://camo.githubusercontent.com/a9b94ba5cd7db1fdd6952701883aaa319612dba7205ff1183b66cbf0666213c1/68747470733a2f2f706f7365722e707567782e6f72672f7375626a6563746976652d7068702f736c696d2d6f7074696f6e732d6d6964646c65776172652f642f6d6f6e74686c79)](https://packagist.org/packages/subjective-php/slim-options-middleware)

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

[](#requirements)

Requires PHP 7.0 (or later).

Composer
--------

[](#composer)

To add the library as a local, per-project dependency use [Composer](http://getcomposer.org)! Simply add a dependency on `subjective-php/slim-options-middleware` to your project's `composer.json` file such as:

```
composer require subjective-php/slim-options-middleware
```

Contact
-------

[](#contact)

Developers may be contacted at:

- [Pull Requests](https://github.com/subjective-php/slim-options-middleware/pulls)
- [Issues](https://github.com/subjective-php/slim-options-middleware/issues)

Project Build
-------------

[](#project-build)

With a checkout of the code get [Composer](http://getcomposer.org) in your PATH and run:

```
composer install
./vendor/bin/phpunit
./vendor/bin/phpcs
```

Slim 3 Example
--------------

[](#slim-3-example)

```
require __DIR__ . '/vendor/autoload.php';

use SubjectivePHP\Slim\Middleware;

// This Slim setting is required for the middleware to work
$app = new Slim\App([
    "settings"  => [
        "determineRouteBeforeAppMiddleware" => true,
    ]
]);

// create the middleware
$optionsMiddleware = new Middleware\OptionsMiddleware('*', ['Authorization', 'Content-Type']);

$app->map(['GET', 'POST'], 'foos', function ($request, $response, $args) {
    return $response;
};

$app->add($optionsMiddleware);

$app->run();
```

#### Send an OPTIONS request to the API

[](#send-an-options-request-to-the-api)

```
curl -i -X OPTIONS http://example.org/foos

```

#### Response will be similar to

[](#response-will-be-similar-to)

```
HTTP/1.1 200 OK
Access-Control-Allow-Headers: Authorization, Content-Type
Access-Control-Allow-Methods: GET, POST, OPTIONS
Access-Control-Allow-Origin: *
Content-Type: text/html; charset=UTF-8
Date: Mon, 22 Apr 2019 12:45:18 GMT
Server: Apache/2.4.18 (Ubuntu)
Content-Length: 0
Connection: keep-alive

```

###  Health Score

18

—

LowBetter than 8% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity4

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity37

Early-stage or recently created project

 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.

### Community

Maintainers

![](https://www.gravatar.com/avatar/a8d287c8b6f54200e7c10080794152779dc84f043fcc35f43ea8d1e9c8818aa0?d=identicon)[chadicus](/maintainers/chadicus)

---

Top Contributors

[![chadicus](https://avatars.githubusercontent.com/u/1182337?v=4)](https://github.com/chadicus "chadicus (12 commits)")

### Embed Badge

![Health badge](/badges/subjective-php-slim-options-middleware/health.svg)

```
[![Health](https://phpackages.com/badges/subjective-php-slim-options-middleware/health.svg)](https://phpackages.com/packages/subjective-php-slim-options-middleware)
```

###  Alternatives

[friendsofsymfony/rest-bundle

This Bundle provides various tools to rapidly develop RESTful API's with Symfony

2.8k73.3M319](/packages/friendsofsymfony-rest-bundle)[php-http/discovery

Finds and installs PSR-7, PSR-17, PSR-18 and HTTPlug implementations

1.3k309.5M1.2k](/packages/php-http-discovery)[nyholm/psr7

A fast PHP7 implementation of PSR-7

1.3k235.4M2.4k](/packages/nyholm-psr7)[pusher/pusher-php-server

Library for interacting with the Pusher REST API

1.5k94.8M293](/packages/pusher-pusher-php-server)[spatie/crawler

Crawl all internal links found on a website

2.8k16.3M52](/packages/spatie-crawler)[react/http

Event-driven, streaming HTTP client and server implementation for ReactPHP

78126.4M414](/packages/react-http)

PHPackages © 2026

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