Home
Docs
GitHub
Pricing
Blog
Log In

Run Sandworm Audit for your App

Get started
Generated on May 17, 2024 via composer

fruitcake/php-cors v1.3.0

Cross-origin resource sharing library for the Symfony HttpFoundation
Package summary
Share
0
issues
1
license
5
MIT
Package created
18 Feb 2022
Version published
12 Oct 2023
Maintainers
1
Total deps
5
Direct deps
1
License
MIT

Issues

0
This package has no issues

Licenses

MIT License

Permissive
OSI Approved
This is a human-readable summary of (and not a substitute for) the license. Disclaimer.
Can
commercial-use
modify
distribute
sublicense
private-use
Cannot
hold-liable
Must
include-copyright
include-license
5 Packages, Including:
fruitcake/php-cors@v1.3.0
symfony/http-foundation@v7.0.7
symfony/polyfill-mbstring@v1.29.0
symfony/polyfill-php80@v1.29.0
symfony/polyfill-php83@v1.29.0
Disclaimer

This deed highlights only some of the key features and terms of the actual license. It is not a license and has no legal value. You should carefully review all of the terms and conditions of the actual license before using the licensed material.

Sandworm is not a law firm and does not provide legal services. Distributing, displaying, or linking to this deed or the license that it summarizes does not create a lawyer-client or any other relationship.

Direct Dependencies

1
All Dependencies CSV
β“˜ This is a list of fruitcake/php-cors 's direct dependencies. Data on all dependencies, including transitive ones, is available via CSV download.
NameVersionSizeLicenseTypeVulnerabilities
symfony/http-foundationv7.0.7-MIT
prod

Visualizations

Frequently Asked Questions

What does fruitcake/php-cors do?

The fruitcake/php-cors package is a library that enables cross-origin resource sharing (CORS) for your http-foundation and kernel-based applications. This PHP package attempts to implement the W3C Recommendation for CORS, ultimately aiding in the process of managing cross-domain requests in a secure manner, which is vital in ensuring the security and smooth operation of your application.

How do you use fruitcake/php-cors?

Usage of the fruitcake/php-cors package starts with requiring and installing it through Composer. Once installed, it can be used either as a standalone library, as middleware with http://stackphp.com/, or even in the Laravel framework. This versatility allows for easy integration into different types of projects.

A typical usage example for using the package as a library would look like below:

<?php

use Fruitcake\Cors\CorsService;

$cors = new CorsService([
    'allowedHeaders'         => ['x-allowed-header', 'x-other-allowed-header'],
    'allowedMethods'         => ['DELETE', 'GET', 'POST', 'PUT'],
    'allowedOrigins'         => ['http://localhost', 'https://*.example.com'],
    'allowedOriginsPatterns' => ['/localhost:\d/'],
    'exposedHeaders'         => ['Content-Encoding'],
    'maxAge'                 => false,
    'supportsCredentials'    => false,
]);

$cors->addActualRequestHeaders(Response $response, $origin);
$cors->handlePreflightRequest(Request $request);
$cors->isActualRequestAllowed(Request $request);
$cors->isCorsRequest(Request $request);
$cors->isPreflightRequest(Request $request);

In this code snippet, a new instance of the CorsService is created with an array of options, defining the allowed Headers, Methods, Origins, etc. Then different methods from the CorsService instance are used for actual request handling.

Where are the fruitcake/php-cors docs?

The primary documentation of the fruitcake/php-cors can be found on the GitHub repository (https://github.com/fruitcake/php-cors.git). This documentation includes everything from the installation guide to usage examples and details on the specific options that can be defined during usage. For further details, users are directed to the repo's README file and the underlying library https://github.com/asm89/stack-cors, from which fruitcake/php-cors is derived.