All Projects → medz → Cors

medz / Cors

Licence: mit
🔮Supported(Laravel/Lumen/PSR-15/Swoft/Slim/ThinkPHP) - PHP CORS (Cross-origin resource sharing) middleware.

Projects that are alternatives of or similar to Cors

Stacker
Stacker - The environment for local web development, ready for use.
Stars: ✭ 356 (+33.83%)
Mutual labels:  laravel, symfony, yii2
Kantphp2
KantPHP Framework V2
Stars: ✭ 75 (-71.8%)
Mutual labels:  laravel, yii2, thinkphp
Hookphp
HookPHP基于C扩展搭建内置AI编程的架构系统-支持微服务部署|热插拔业务组件-集成业务模型|权限模型|UI组件库|多模板|多平台|多域名|多终端|多语言-含常驻内存|前后分离|API平台|LUA QQ群:679116380
Stars: ✭ 575 (+116.17%)
Mutual labels:  laravel, symfony, thinkphp
Identity Card
A simple proof of identity card of the people's Republic of China.
Stars: ✭ 154 (-42.11%)
Mutual labels:  laravel, symfony, thinkphp
Easy Short Url
ESU 短网址,可在 Laravel、Yii、ThinkPHP 等框架 Composer 包引入,也可以独立搭建短网址站点
Stars: ✭ 71 (-73.31%)
Mutual labels:  laravel, yii2, thinkphp
Search Engine Rank
🐘根据网站关键词,获取网站在各大搜索引擎(百度、360、搜狗)的排名情况,有利于网站seo
Stars: ✭ 197 (-25.94%)
Mutual labels:  laravel, yii2, thinkphp
reqres
Powerful classes for http requests and responses
Stars: ✭ 36 (-86.47%)
Mutual labels:  request, response
chronosjs
JS Channels (Events / Commands / Reqest-Response / Courier) Mechanism
Stars: ✭ 35 (-86.84%)
Mutual labels:  request, response
php-framework-benchmark
php framework benchmark (include laravel、symfony、silex、lumen、slim、yii2、tastphp etc)
Stars: ✭ 17 (-93.61%)
Mutual labels:  yii2, laravel5
HttpUtility
HttpUtility is an open source MIT license project which is helpful in making HTTP requests and returns a decoded object from server. Right now this utility only parses JSON.
Stars: ✭ 28 (-89.47%)
Mutual labels:  request, response
Vue Gates
🔒 A Vue.js & Nuxt.js plugin that allows you to use roles and permissions in your components or DOM elements, also compatible as middleware and methods.
Stars: ✭ 184 (-30.83%)
Mutual labels:  middleware, laravel
active endpoint
[ARCHIVE] 🔧 ActiveEndpoint is middleware for Rails application that collect and analize request and response per request for route endpoint. It works with minimum affecting to application response time.
Stars: ✭ 13 (-95.11%)
Mutual labels:  request, response
net
A small, modern, PSR-7 compatible PSR-17 and PSR-18 network library for PHP, inspired by Go's net package.
Stars: ✭ 16 (-93.98%)
Mutual labels:  request, response
Csaguzzlebundle
A bundle integrating Guzzle >=4.0 in Symfony
Stars: ✭ 248 (-6.77%)
Mutual labels:  middleware, symfony
Laravel Multisite
Multiple sites on one codebase
Stars: ✭ 214 (-19.55%)
Mutual labels:  middleware, laravel
WaterPipe
URL routing framework, requests/responses handler, and HTTP client for PHP
Stars: ✭ 24 (-90.98%)
Mutual labels:  request, response
Laravel Shield
A HTTP basic auth middleware for Laravel
Stars: ✭ 193 (-27.44%)
Mutual labels:  middleware, laravel
izzyparser-ios
IzzyParser is an iOS library for serializing and deserializing JSON:API objects
Stars: ✭ 19 (-92.86%)
Mutual labels:  request, response
geggleto-acl
PSR-7 Zend ACL implementation - Permission Library [ slim, psr7, acl, permissions, zend ]
Stars: ✭ 33 (-87.59%)
Mutual labels:  middleware, slim
servie
Standard, framework-agnostic HTTP interfaces for JavaScript servers and clients
Stars: ✭ 39 (-85.34%)
Mutual labels:  request, response

CORS

PHP Composer StyleCI Build Status FOSSA Status

PHP CORS (Cross-origin resource sharing) middleware.

Support

Using

composer require medz/cors

Example:

use Medz\Cors\Cors;

$cors = new Cors($config); // The $config 👉 `config/cors.php` file.
$cors->setRequest($requestType, $request); // The $request is empty array or is `NULL` or $_REQUEST
$cors->setResponse($responseType, $response); // The $response is empty array.
$cors->handle();

$response = $cors->getResponse();

Both $requestType and $responseType are of any type that is individually set to support, but if used in a framework, these two values are usually the same. Because you can set it up individually, you can deliver different values depending on your needs to achieve your goals.

Configure

The config example:

$config = [
    'allow-credentials' => false, // set "Access-Control-Allow-Credentials" 👉 string "false" or "true".
    'allow-headers'      => ['*'], // ex: Content-Type, Accept, X-Requested-With
    'expose-headers'     => [],
    'origins'            => ['*'], // ex: http://localhost
    'methods'            => ['*'], // ex: GET, POST, PUT, PATCH, DELETE
    'max-age'            => 0,
];

Array

use Medz\Cors\Cors;

$cors = new Cors($config);
$cors->setRequest('array', $request);
$cors->setResponse('array', $response);
$cors->handle();

$responseHeadersArray = $cors->getResponse();

PSR-7

use Medz\Cors\Cors;

$cors = new Cors($config);
$cors->setRequest('psr-7', $request);
$cors->setResponse('psr-7', $response);

$response = $cors->getResponse();

Other

Because of the interface features provided by this package, you can implement it in a small amount of code in any other framework.

Excellent Repositories

License

The component is open-sourced software licensed under the MIT license.

FOSSA Status

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].