Home
Docs
GitHub
Pricing
Blog
Log In

Run Sandworm Audit for your App

Get started
Hold on, we're currently generating a fresh version of this report
Generated on May 10, 2024 via composer

asm89/stack-cors v2.1.1

Cross-origin resource sharing library and stack middleware
Package summary
Share
0
issues
1
license
14
MIT
Package created
14 Aug 2013
Version published
18 Jan 2022
Maintainers
2
Total deps
14
Direct deps
2
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
14 Packages, Including:
asm89/stack-cors@v2.1.1
psr/event-dispatcher@1.0.0
psr/log@3.0.0
symfony/deprecation-contracts@v3.5.0
symfony/error-handler@v7.0.7
symfony/event-dispatcher@v7.0.7
symfony/event-dispatcher-contracts@v3.5.0
symfony/http-foundation@v6.4.7
symfony/http-kernel@v6.4.7
symfony/polyfill-ctype@v1.29.0
symfony/polyfill-mbstring@v1.29.0
symfony/polyfill-php80@v1.29.0
symfony/polyfill-php83@v1.29.0
symfony/var-dumper@v7.0.7
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

2
All Dependencies CSV
β“˜ This is a list of asm89/stack-cors 's direct dependencies. Data on all dependencies, including transitive ones, is available via CSV download.
NameVersionSizeLicenseTypeVulnerabilities
symfony/http-foundationv6.4.7-MIT
prod dev
symfony/http-kernelv6.4.7-MIT
prod dev

Visualizations

Frequently Asked Questions

What does asm89/stack-cors do?

Asm89/Stack-CORS is a PHP library and middleware that enables Cross-Origin Resource Sharing (CORS) for your HTTP applications. In detail, it tries to implement the W3C's CORS recommendation, thereby allowing web applications running on one origin to access selected resources from a different origin. This plays an exemplary role in boosting web applications' security accompanied by the relaxation in accessing data from different origins.

How do you use asm89/stack-cors?

Asm89/Stack-CORS is conveniently usable as either a library or a stack middleware. Installation is simple using Composer with asm89/stack-cors.
To start using it as a library, you can make use of the CorsService class and define your CORS settings. Here is an example:

use Asm89\Stack\CorsService;

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

// assigning actual request headers
$cors->addActualRequestHeaders(Response $response, $origin);

// handling preflight request
$cors->handlePreflightRequest(Request $request);

// approving actual request
$cors->isActualRequestAllowed(Request $request);

// checking CORS request
$cors->isCorsRequest(Request $request);

// handling preflight request
$cors->isPreflightRequest(Request $request);

Similarly, to use it as a stack middleware:

use Asm89\Stack\Cors;

$app = new Cors($app, [
    'allowedHeaders' => ['x-allowed-header', 'x-other-allowed-header'],
    'allowedMethods' => ['DELETE', 'GET', 'POST', 'PUT'],
    'allowedOrigins' => ['localhost'],
    'allowedOriginsPatterns' => ['/localhost:\d/'],
    'exposedHeaders' => false,
    'maxAge' => false,
    'supportsCredentials' => false,
]);

Remember that configurations like 'allowedHeaders', 'allowedMethods', and 'allowedOrigins', accept an array value including '*' to allow any headers, methods, or requests from any origin respectively.

Where are the asm89/stack-cors docs?

For more detailed and technical documentation on asm89/stack-cors, you can refer to the README on the official GitHub repository. The documentation contains comprehensive guidelines about installation, usage, and options that you can set. Additionally, it provides useful examples to illustrate how to work with the library and the stack middleware.