Download the PHP package andrewdyer/cors-response-emitter without Composer

On this page you can find all versions of the php package andrewdyer/cors-response-emitter. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package cors-response-emitter

CORS Response Emitter

A CORS-aware response emitter for Slim Framework applications that applies consistent CORS and cache-control headers.

Latest Stable Version Total Downloads License PHP Version Require

Introduction

This library applies CORS and cache-control headers when emitting Slim responses. It checks the incoming request origin against an explicit allowlist, returns credentialed CORS responses for trusted origins, and supports wildcard responses for public APIs without credentials. Cache-control headers are applied consistently across emitted responses.

Prerequisites

Installation

Getting Started

The examples below demonstrate how to configure the emitter and emit a Slim response with CORS headers.

1. Configure trusted origins

Provide an allowlist of origins that may receive credentialed CORS responses.

2. Emit the response

After Slim handles the request, pass the response to the emitter.

Usage

The emitter resolves CORS headers from the request origin and allowlist configuration:

Scenario Access-Control-Allow-Origin Access-Control-Allow-Credentials Vary
Request origin matches an explicit allowlist entry Reflected origin (e.g. https://app.example.com) true Origin
"*" in allowlist, no explicit match * (omitted) (omitted)
No match and no wildcard allowlist entry (omitted) (omitted) (omitted)

Allow exact origins

Use explicit origins when endpoints need credentialed cross-origin requests.

Allow any origin for public APIs

A wildcard origin ("*") may be configured as an allowlist entry to permit requests from any origin. This is suitable for fully public, unauthenticated APIs:

Combine exact and wildcard origins

Explicit origins and "*" may be combined. An exact match always takes precedence and receives the credentialed response. Requests from any other origin fall back to the uncredentialed wildcard response:

Important: the CORS specification forbids sending Access-Control-Allow-Credentials: true with Access-Control-Allow-Origin: *. If an endpoint requires cookies, HTTP authentication, or client certificates, use explicit origins.

Complete Example

The following example combines Slim setup, request handling, and CORS-aware response emission:

License

Licensed under the MIT license and is free for private or commercial projects.


All versions of cors-response-emitter with dependencies

PHP Build Version
Package Version
Requires php Version ^8.3
slim/psr7 Version ^1.8
slim/slim Version ^4.12
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package andrewdyer/cors-response-emitter contains the following files

Loading the files please wait ...