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

Abandoned → [ozee31/cakephp-cors](/?search=ozee31%2Fcakephp-cors)Cakephp-plugin[HTTP &amp; Networking](/categories/http)

snelg/cakephp-cors
==================

Cors plugin for CakePHP

192.2k2[2 issues](https://github.com/snelg/cakephp-cors/issues)PHP

Since Mar 3Pushed 9y ago1 watchersCompare

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

READMEChangelogDependenciesVersions (1)Used By (0)

CORS plugin for CakePHP 3.0-3.2
===============================

[](#cors-plugin-for-cakephp-30-32)

[![Build Status](https://camo.githubusercontent.com/08ddce226c7fe1e9ae415e3fd19792e4728c8eee6adf4e3bc98387b85d02c3e1/68747470733a2f2f7472617669732d63692e6f72672f4c65576573746f706865722f63616b657068702d636f72732e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/LeWestopher/cakephp-cors)[![Coverage](https://camo.githubusercontent.com/1b01b4615ec57a66298f36e73c8a1c3d5340759f7a89e4bf19f687e3d078992c/68747470733a2f2f696d672e736869656c64732e696f2f636f766572616c6c732f4c65576573746f706865722f63616b657068702d636f72732f6d61737465722e737667)](https://travis-ci.org/snelg/cakephp-cors)[![Downloads](https://camo.githubusercontent.com/7e8a7bee11ea9ddc52b46c067a1c84c775f618ff7bfa4cf2e0cb9e825a0ec127/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f736e656c672f63616b657068702d636f72732e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/snelg/cakephp-cors)

A simple plugin to add CORS headers to specified requests.

\#For CakePHP 3.3+, use

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

[](#requirements)

- CakePHP 3.0-3.2
- PHP 5.4+

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

[](#installation)

You can install this plugin into your CakePHP application using [composer](http://getcomposer.org).

To install this plugin, in your terminal type:

```
composer require snelg/cakephp-cors:dev-master

```

### Unlocking CORS for a single controller

[](#unlocking-cors-for-a-single-controller)

Define a single key within the routes array in the DispatcherFactory options array:

```
DispatcherFactory::add('Cors.Cors', ['routes' => [
    'ControllerClassName'
]]);
```

### Unlocking CORS for a controller scoped to a single action

[](#unlocking-cors-for-a-controller-scoped-to-a-single-action)

Define a nested array consisting of 'controller' =&gt; 'action' within the routes array in DispatcherFactor options:

```
DispatcherFactory::add('Cors.Cors', ['routes' => [
    'ControllerClassName' => 'some_action',
]]);
```

### Scoping CORS to particular origins

[](#scoping-cors-to-particular-origins)

```
DispatcherFactory::add('Cors.Cors', ['routes' => [
    'ControllerClassName' => [
        'action_one' => ['origin' => 'somesite.com']
]]);
```

### Scoping CORS to particular methods

[](#scoping-cors-to-particular-methods)

```
DispatcherFactory::add('Cors.Cors', ['routes' => [
   'ControllerClassName' => [
       'action_one' => [
           'origin' => 'somesite.com',
           'methods' => ['PUT', 'DELETE']
       ]
]]);
```

### Setting CORS within Router::connect

[](#setting-cors-within-routerconnect)

```
Router::scope('/', function ($routes) {
    $routes->connect('/public_api',
    ['controller' => 'ControllerClass', 'action' => 'action_one', 'cors' => true]]
});
}
```

### Router::connect with custom origins, methods, and headers

[](#routerconnect-with-custom-origins-methods-and-headers)

```
Router::scope('/', function ($routes) {
    $routes->connect('/public_api', [
        'controller' => 'ControllerClass',
        'action' => 'action_one',
        'cors' => [
            'origin' => 'your_origin.com',
            'methods' => ['PUT', 'DELETE'],
            'headers' => []
        ]
    ]);
});
}
```

### Support

[](#support)

For bugs and feature requests, please use the [issues](https://github.com/snelg/cakephp-cors/issues) section of this repository.

### Contributing

[](#contributing)

To contribute to this plugin please follow a few basic rules.

- Contributions must follow the [CakePHP coding standard](http://book.cakephp.org/3.0/en/contributing/cakephp-coding-conventions.html).
- [Unit tests](http://book.cakephp.org/3.0/en/development/testing.html) are required.

### Creators

[](#creators)

[Glen Sawyer](http://www.github.com/snelg) &amp;&amp; [Wes King](http://www.github.com/lewestopher)

### License

[](#license)

Copyright 2015, Glen Sawyer and Wes King

Licensed under The MIT License Redistributions of files must retain the above copyright notice.

###  Health Score

26

—

LowBetter than 43% of packages

Maintenance18

Infrequent updates — may be unmaintained

Popularity25

Limited adoption so far

Community14

Small or concentrated contributor base

Maturity41

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 56.3% 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/93d82c78714b6af2fc1197d8179383dad13f385d79456cceeb260f12b7742840?d=identicon)[snelg](/maintainers/snelg)

![](https://www.gravatar.com/avatar/4f75d8c4dbe70d9d4ef7b8092d70c8bfb5403b32c8462374ef0ccad49f9b8f6f?d=identicon)[lewestopher](/maintainers/lewestopher)

---

Top Contributors

[![snelg](https://avatars.githubusercontent.com/u/5741887?v=4)](https://github.com/snelg "snelg (18 commits)")[![LeWestopher](https://avatars.githubusercontent.com/u/5728795?v=4)](https://github.com/LeWestopher "LeWestopher (11 commits)")[![jadb](https://avatars.githubusercontent.com/u/33527?v=4)](https://github.com/jadb "jadb (2 commits)")[![bravo-kernel](https://avatars.githubusercontent.com/u/230500?v=4)](https://github.com/bravo-kernel "bravo-kernel (1 commits)")

### Embed Badge

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

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

###  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)[pusher/pusher-php-server

Library for interacting with the Pusher REST API

1.5k94.8M293](/packages/pusher-pusher-php-server)[react/http

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

78026.4M414](/packages/react-http)[php-http/curl-client

PSR-18 and HTTPlug Async client with cURL

48347.0M384](/packages/php-http-curl-client)[smi2/phpclickhouse

PHP ClickHouse Client

84310.1M71](/packages/smi2-phpclickhouse)

PHPackages © 2026

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