PHP CORSPHP 跨域資源共享中間件
CORS
這是一個(gè) PHP 跨域資源共享 (CORS Cross-origin resource sharing) 中間件。
支持
Array, 原生 PHP 代碼
使用 PSR-7
Laravel
Symfony
使用
composer require medz/cors
示例
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();
$requestType 和 $responseType 都是單獨(dú)設(shè)置支持的類(lèi)型,但如果在框架中使用,這兩個(gè)值通常是相同的。因?yàn)槟憧梢詥为?dú)設(shè)置它,所以你可以根據(jù)自己的需要提供不同的值以實(shí)現(xiàn)你的目標(biāo)。
評(píng)論
圖片
表情
