PHPackages                             los/los-cors - 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. los/los-cors

ActiveLibrary

los/los-cors
============

PHP CORS middleware

2.1.0(10mo ago)110.6k↑42.9%2MITPHPPHP ^8.2

Since Sep 14Pushed 10mo ago1 watchersCompare

[ Source](https://github.com/Lansoweb/los-cors)[ Packagist](https://packagist.org/packages/los/los-cors)[ Docs](https://github.com/lansoweb/los-cors)[ RSS](/packages/los-los-cors/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (2)Dependencies (8)Versions (7)Used By (0)

CORS Middleware for PHP
=======================

[](#cors-middleware-for-php)

This middleware handles CORS requests and adds cors headers

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

[](#installation)

This middleware can be installed with composer.

```
$ composer require los/los-cors
```

Usage
-----

[](#usage)

Include the `Los\Cors\CorsMiddleware` and it's factory `Los\Cors\CorsMiddlewareFactory` to your pipeline and use the configuration bellow.

```
/**
  * Set the list of allowed origins domain with protocol.
  * For example:
  * 'allowed_origins' => ['http://www.mysite.com','https://api.mysite.com'],
  */
'allowed_origins' => ['*'],

 /**
  * Set the list of HTTP verbs.
  */
'allowed_methods' => ['GET', 'OPTIONS'],

 /**
  * Set the list of allowed headers. This is returned in the preflight request to indicate
  * which HTTP headers can be used when making the actual request
  */
'allowed_headers' => ['Authorization', 'Accept', 'Content-Type'],

 /**
  * Set the max age of the preflight request in seconds. A non-zero max age means
  * that the preflight will be cached during this amount of time
  */
'max_age' => 120,

 /**
  * Set the list of exposed headers. This is a whitelist that authorize the browser
  * to access to some headers using the getResponseHeader() JavaScript method. Please
  * note that this feature is buggy and some browsers do not implement it correctly
  */
'expose_headers' => [],

 /**
  * Standard CORS requests do not send or set any cookies by default. For this to work,
  * the client must set the XMLHttpRequest's "withCredentials" property to "true". For
  * this to work, you must set this option to true so that the server can serve
  * the proper response header.
  */
'allowed_credentials' => false,
```

### Laminas / Mezzio

[](#laminas--mezzio)

If you are using [mezzio-skeleton](https://github.com/mezzio/mezzio-skeleton), you can copy `config/los-cors.global.php.dist` to `config/autoload/los-cors.global.php` and modify the configuration as needed.

###  Health Score

47

—

FairBetter than 94% of packages

Maintenance54

Moderate activity, may be stable

Popularity28

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity80

Battle-tested with a long release history

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

Total

5

Last Release

308d ago

Major Versions

0.9.0 → 1.0.02016-09-14

1.1.0 → 2.0.02023-10-30

PHP version history (4 changes)0.9.0PHP ^7.0

1.1.0PHP ^7.1

2.0.0PHP ^8.1

2.1.0PHP ^8.2

### Community

Maintainers

![](https://www.gravatar.com/avatar/5b54dffc1ebcb317a0cf825a781ab6c5f30980e9abd0d0a3f9c68830cb05c014?d=identicon)[Lansoweb](/maintainers/Lansoweb)

---

Top Contributors

[![Lansoweb](https://avatars.githubusercontent.com/u/2109813?v=4)](https://github.com/Lansoweb "Lansoweb (8 commits)")

###  Code Quality

Static AnalysisPHPStan

Code StylePHP\_CodeSniffer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/los-los-cors/health.svg)

```
[![Health](https://phpackages.com/badges/los-los-cors/health.svg)](https://phpackages.com/packages/los-los-cors)
```

###  Alternatives

[cakephp/cakephp

The CakePHP framework

8.8k18.5M1.6k](/packages/cakephp-cakephp)[thecodingmachine/graphqlite

Write your GraphQL queries in simple to write controllers (using webonyx/graphql-php).

5723.1M30](/packages/thecodingmachine-graphqlite)[cakephp/authentication

Authentication plugin for CakePHP

1153.6M67](/packages/cakephp-authentication)[rareloop/lumberjack-core

A powerful MVC framework for the modern WordPress developer. Write better, more expressive and easier to maintain code

42155.0k19](/packages/rareloop-lumberjack-core)[neos/flow

Flow Application Framework

862.0M451](/packages/neos-flow)[neos/flow-development-collection

Flow packages in a joined repository for pull requests.

144179.3k3](/packages/neos-flow-development-collection)

PHPackages © 2026

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