Download the PHP package laminas-commons/lmc-cors without Composer

On this page you can find all versions of the php package laminas-commons/lmc-cors. 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 lmc-cors

Important: This library is abandoned.
Please use LM-Commons/LmcCors.

LmcCors

Build Status Scrutinizer Code Quality Coverage Status

LmcCors is a simple Laminas MVC module that helps you to deal with Cross-Origin Resource Sharing (CORS).

What is LmcCors ?

LmcCors is a Laminas MVC module that allow to easily configure your Laminas MVC application so that it automatically builds HTTP responses that follow the CORS documentation.

Installation

Install the module by typing (or add it to your composer.json file):

Then, enable it by adding "LmcCors" in your application.config.php or modules.config.php file.

By default, LmcCors is configured to deny every CORS requests. To change that, you need to copy the config/lmc_cors.global.php.dist file to your autoload folder (remove the .dist extension), and modify it to suit your needs.

Documentation

What is CORS ?

CORS is a mechanism that allows to perform cross-origin requests from your browser.

For instance, let's say that your website is hosted in the domain http://example.com. By default, user agents won't be allowed to perform AJAX requests to another domain for security reasons (for instance http://funny-domain.com).

With CORS, you can allow your server to reply to such requests.

You can find better documentation on how CORS works on the web:

Event registration

LmcCors registers the LmcCors\Mvc\CorsRequestListener with the MvcEvent::EVENT_ROUTE event, with a priority of -1. This means that this listener is executed AFTER the route has been matched.

Configuring the module

As by default, all the various options are set globally for all routes:

If you want to configure specific routes, you can add ZfrCors\Options\CorsOptions::ROUTE_PARAM to your route configuration:

Preflight request

If LmcCors detects a preflight CORS request, a new HTTP response will be created, and LmcCors will send the appropriate headers according to your configuration. The response will always be sent with a 200 status code (OK).

Please note that this will also prevent further MVC steps from being executed, since all subsequent MVC steps are skipped till Laminas\Mvc\MvcEvent::EVENT_FINISH, which is responsible for actually sending the response.

Actual request

When an actual request is made, LmcCors first checks it the origin is allowed. If it is not, then a new response with a 403 status code (Forbidden) is created and sent.

Please note that this will also prevent further MVC steps from being executed, since all subsequent MVC steps are skipped till Laminas\Mvc\MvcEvent::EVENT_FINISH, which is responsible for actually sending the response.

If the origin is allowed, LmcCors will just add the appropriate headers to the request produced by Laminas\Mvc.

Security concerns

Don't use this module to secure your application! You must use a proper authorization module, like BjyAuthorize, LmcRbacMvc or SpiffyAuthorize.

LmcCors only allows to accept or refuse a cross-origin request.

Custom schemes

Internally, LmcCors uses Laminas\Uri\UriFactory class. If you are using custom schemes (for instance if you are testing your API with some Google Chrome extensions), you need to add support for those schemes by adding them to the UriFactory config (please refer to the doc).

Example

To register the chrome-extension custom scheme in your API, simply add:

to the onBootstrap() method in module/Application/Module.php.

Registering the chrome-extension custom scheme like this allows you to use Google Chrome extensions for testing your API.


All versions of lmc-cors with dependencies

PHP Build Version
Package Version
Requires php Version ^7.2
laminas/laminas-eventmanager Version ^2.6.4 || ^3.2.1
laminas/laminas-http Version ^2.10
laminas/laminas-mvc Version ^2.7.15 || ^3.1.1
laminas/laminas-servicemanager Version ^2.7.9 || ^3.4.0
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 laminas-commons/lmc-cors contains the following files

Loading the files please wait ....