{"id":15063235,"url":"https://github.com/fruitcake/php-cors","last_synced_at":"2025-05-14T08:09:32.382Z","repository":{"id":39891667,"uuid":"460938824","full_name":"fruitcake/php-cors","owner":"fruitcake","description":"CORS (Cross-Origin Resource Sharing) for your Symfony/Laravel requests","archived":false,"fork":false,"pushed_at":"2025-03-13T13:43:06.000Z","size":146,"stargazers_count":274,"open_issues_count":4,"forks_count":16,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-05-14T04:42:22.555Z","etag":null,"topics":["cors","hacktoberfest","laravel","php","symfony"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/fruitcake.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null},"funding":{"github":"barryvdh","custom":["https://fruitcake.nl"]}},"created_at":"2022-02-18T17:08:22.000Z","updated_at":"2025-05-05T01:07:07.000Z","dependencies_parsed_at":"2024-04-09T09:25:38.875Z","dependency_job_id":"d465d498-7c56-4264-a2f0-bfa1a1cd2ada","html_url":"https://github.com/fruitcake/php-cors","commit_stats":{"total_commits":137,"total_committers":20,"mean_commits":6.85,"dds":0.5547445255474452,"last_synced_commit":"bb96f0246364ea36d4d22364a39023a7e2974fc8"},"previous_names":[],"tags_count":11,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fruitcake%2Fphp-cors","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fruitcake%2Fphp-cors/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fruitcake%2Fphp-cors/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fruitcake%2Fphp-cors/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/fruitcake","download_url":"https://codeload.github.com/fruitcake/php-cors/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254101558,"owners_count":22014908,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cors","hacktoberfest","laravel","php","symfony"],"created_at":"2024-09-24T23:53:44.075Z","updated_at":"2025-05-14T08:09:27.373Z","avatar_url":"https://github.com/fruitcake.png","language":"PHP","funding_links":["https://github.com/sponsors/barryvdh","https://fruitcake.nl"],"categories":[],"sub_categories":[],"readme":"# CORS for PHP (using the Symfony HttpFoundation)\n\n[![Unit Tests](https://github.com/fruitcake/php-cors/actions/workflows/run-tests.yml/badge.svg)](https://github.com/fruitcake/php-cors/actions)\n[![PHPStan Level 9](https://img.shields.io/badge/PHPStan-Level%2010-blue)](https://github.com/fruitcake/php-cors/actions)\n[![Code Coverage](https://img.shields.io/badge/CodeCoverage-100%25-brightgreen)](https://github.com/fruitcake/php-cors/actions/workflows/run-coverage.yml)\n[![Packagist License](https://img.shields.io/badge/Licence-MIT-blue)](http://choosealicense.com/licenses/mit/)\n[![Latest Stable Version](https://img.shields.io/packagist/v/fruitcake/php-cors?label=Stable)](https://packagist.org/packages/fruitcake/php-cors)\n[![Total Downloads](https://img.shields.io/packagist/dt/fruitcake/php-cors?label=Downloads)](https://packagist.org/packages/fruitcake/php-cors)\n[![Fruitcake](https://img.shields.io/badge/Powered%20By-Fruitcake-b2bc35.svg)](https://fruitcake.nl/)\n\nLibrary and middleware enabling cross-origin resource sharing for your\nhttp-{foundation,kernel} using application. It attempts to implement the\n[W3C Recommendation] for cross-origin resource sharing.\n\n[W3C Recommendation]: http://www.w3.org/TR/cors/\n\n\u003e Note: This is a standalone fork of https://github.com/asm89/stack-cors and is compatible with the options for CorsService.\n## Installation\n\nRequire `fruitcake/php-cors` using composer.\n\n## Usage\n\nThis package can be used as a library. You can use it in your framework using:\n\n - [Stack middleware](http://stackphp.com/): https://github.com/asm89/stack-cors\n - [Laravel](https://laravel.com): https://github.com/fruitcake/laravel-cors\n \n\n### Options\n\n| Option                 | Description                                                | Default value |\n|------------------------|------------------------------------------------------------|---------------|\n| allowedMethods         | Matches the request method.                                | `[]`          |\n| allowedOrigins         | Matches the request origin.                                | `[]`          |\n| allowedOriginsPatterns | Matches the request origin with `preg_match`.              | `[]`          |\n| allowedHeaders         | Sets the Access-Control-Allow-Headers response header.     | `[]`          |\n| exposedHeaders         | Sets the Access-Control-Expose-Headers response header.    | `[]`          |\n| maxAge                 | Sets the Access-Control-Max-Age response header.           | `0`           |\n| supportsCredentials    | Sets the Access-Control-Allow-Credentials header.          | `false`       |\n\nThe _allowedMethods_ and _allowedHeaders_ options are case-insensitive.\n\nYou don't need to provide both _allowedOrigins_ and _allowedOriginsPatterns_. If one of the strings passed matches, it is considered a valid origin. A wildcard in allowedOrigins will be converted to a pattern.\n\nIf `['*']` is provided to _allowedMethods_, _allowedOrigins_ or _allowedHeaders_ all methods / origins / headers are allowed.\n\n\u003e Note: Allowing a single static origin will improve cacheability.\n\n### Example: using the library\n\n```php\n\u003c?php\n\nuse Fruitcake\\Cors\\CorsService;\n\n$cors = new CorsService([\n    'allowedHeaders'         =\u003e ['x-allowed-header', 'x-other-allowed-header'],\n    'allowedMethods'         =\u003e ['DELETE', 'GET', 'POST', 'PUT'],\n    'allowedOrigins'         =\u003e ['http://localhost', 'https://*.example.com'],\n    'allowedOriginsPatterns' =\u003e ['/localhost:\\d/'],\n    'exposedHeaders'         =\u003e ['Content-Encoding'],\n    'maxAge'                 =\u003e 0,\n    'supportsCredentials'    =\u003e false,\n]);\n\n$cors-\u003eaddActualRequestHeaders(Response $response, $origin);\n$cors-\u003ehandlePreflightRequest(Request $request);\n$cors-\u003eisActualRequestAllowed(Request $request);\n$cors-\u003eisCorsRequest(Request $request);\n$cors-\u003eisPreflightRequest(Request $request);\n```\n\n## License\n\nReleased under the MIT License, see [LICENSE](LICENSE).\n\n\u003e This package is split-off from https://github.com/asm89/stack-cors and developed as stand-alone library since 2022\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffruitcake%2Fphp-cors","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffruitcake%2Fphp-cors","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffruitcake%2Fphp-cors/lists"}