PHPackages                             lithemod/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. [HTTP &amp; Networking](/categories/http)
4. /
5. lithemod/cors

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

lithemod/cors
=============

Configures Cross-Origin Resource Sharing (CORS) headers for your Lithe application.

v1.0.0(1y ago)28MITPHPPHP ^8.0

Since Oct 2Pushed 1y agoCompare

[ Source](https://github.com/lithemod/cors)[ Packagist](https://packagist.org/packages/lithemod/cors)[ RSS](/packages/lithemod-cors/feed)WikiDiscussions master Synced 2d ago

READMEChangelogDependencies (2)Versions (2)Used By (0)

CORS
====

[](#cors)

The CORS (Cross-Origin Resource Sharing) middleware in Lithe configures CORS headers to allow or restrict access to resources from different origins.

---

Installing the CORS Module
--------------------------

[](#installing-the-cors-module)

To use the CORS middleware in your Lithe project, you need to install the `lithemod/cors` package. Follow the steps below:

1. **Make sure you have Composer installed**. Composer is a dependency management tool for PHP.
2. **Open your terminal** and navigate to your Lithe project directory.
3. **Run the following command to install the module**:

    ```
    composer require lithemod/cors
    ```

    This will download and install the CORS module in your project, as well as automatically register any necessary dependencies.

Using the CORS Middleware
-------------------------

[](#using-the-cors-middleware)

The CORS middleware in Lithe is responsible for configuring Cross-Origin Resource Sharing headers, allowing or restricting access to your application's resources from different origins. To configure it in your application, add it using the `use()` method:

```
use Lithe\Middleware\Configuration\cors;

$app->use(cors());
```

### Configuring the CORS Middleware

[](#configuring-the-cors-middleware)

The CORS middleware can be configured with the following parameters:

- **origins**: Allowed origin(s) for accessing your resources. It can be a string or an array of strings. The default is `'*'` (any origin).
- **methods**: Allowed HTTP methods. The default is `'GET, POST, OPTIONS'`.
- **headers**: Allowed headers. It can be a string or an array of strings. The default is `'Origin, X-Requested-With, Content-Type, Accept'`.
- **credentials**: Indicates if credentials (such as cookies or authorization headers) are allowed. The default is `true`.
- **maxAge**: Time in seconds for caching the results of a preflight request. The default is `null`.

### Example Configuration:

[](#example-configuration)

```
$app->use(cors([
    'origins' => ['https://example.com', 'https://another.com'],
    'methods' => 'GET, POST, PUT, DELETE, OPTIONS',
    'headers' => ['Content-Type', 'Authorization'],
    'credentials' => true,
    'maxAge' => 86400,
]));
```

### Middleware Behavior

[](#middleware-behavior)

- **Allowed Origins**: The middleware sets the `Access-Control-Allow-Origin` header with the allowed origins.
- **Allowed Methods**: Sets the `Access-Control-Allow-Methods` header with the permitted HTTP methods.
- **Allowed Headers**: Sets the `Access-Control-Allow-Headers` header with the allowed headers.
- **Credentials**: Sets the `Access-Control-Allow-Credentials` header to allow credentials if configured as `true`.
- **Cache Duration**: Sets the `Access-Control-Max-Age` header to specify the duration for caching preflight requests.
- **Handling OPTIONS Requests**: The middleware handles OPTIONS (preflight) requests by returning a 200 OK status and terminating the response.

Considerations
--------------

[](#considerations)

- **Specific Origins**: If you specify concrete origins, only those origins will be able to access your resources.
- **HTTP Methods and Headers**: Configure the methods and headers according to your application's needs to ensure security and compatibility.
- **Preflight Requests**: The middleware ensures that OPTIONS requests are handled properly to support preflight requests.

###  Health Score

25

—

LowBetter than 35% of packages

Maintenance34

Infrequent updates — may be unmaintained

Popularity7

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity44

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

Unknown

Total

1

Last Release

640d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/56173de3a7bf7099dd8168efd730d3c2fb5df5174a123fdc37cee8c3589e2345?d=identicon)[williamhumbwavali](/maintainers/williamhumbwavali)

---

Top Contributors

[![williamhumbwavali](https://avatars.githubusercontent.com/u/127023095?v=4)](https://github.com/williamhumbwavali "williamhumbwavali (1 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

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

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

###  Alternatives

[php-http/cache-plugin

PSR-6 Cache plugin for HTTPlug

25126.1M82](/packages/php-http-cache-plugin)[illuminate/http

The Illuminate Http package.

11937.9M6.9k](/packages/illuminate-http)[rdkafka/rdkafka

A PHP extension for Kafka

2.2k24.3k1](/packages/rdkafka-rdkafka)[httpsoft/http-message

Strict and fast implementation of PSR-7 and PSR-17

87965.9k114](/packages/httpsoft-http-message)[mezzio/mezzio-router

Router subcomponent for Mezzio

265.4M92](/packages/mezzio-mezzio-router)[serpapi/google-search-results-php

Get Google, Bing, Baidu, Ebay, Yahoo, Yandex, Home depot, Naver, Apple, Duckduckgo, Youtube search results via SerpApi.com

69127.2k](/packages/serpapi-google-search-results-php)

PHPackages © 2026

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