Download the PHP package shiftonelabs/laravel-cors without Composer

On this page you can find all versions of the php package shiftonelabs/laravel-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 laravel-cors

laravel-cors

Latest Version on Packagist Build Status Coverage Status Quality Score Total Downloads

This Laravel package provides support for enabling CORS requests in a Laravel application. If basic CORS support is needed, there are two other popular packages that are widely used (barryvdh/laravel-cors and spatie/laravel-cors).

This package attempts to solve a couple issues with the other packages. These issues are not show stoppers, so you may want to look at the other packages if these issues are not important to you.

1. Multiple Configurations

While the other packages do support applying the CORS middleware to specific routes, they still only support one global configuration. So, for example, if you wanted one set of routes to be available to only one origin, and another set of routes to be available for a different origin, you can't create that configuration without making both sets of routes available to both origins.

This package allows specifying multiple configurations, which can be applied as needed per route.

2. Error Handling

In the other packages, if an error occurred before the CORS middleware was applied, the CORS headers would not be added to the error response. In this case, instead of getting a response with the error, you would get an invalid CORS request error and not have access to the response.

This package works to ensure the CORS configuration is applied to the request, even in the case of an error.

3. Preflight Issues

Versions

This package is meant for Laravel 5.1 through Laravel 6.x. It does not yet support Lumen. This package uses middleware, and therefore does not support Laravel < 5.0. This package requires the Kernel::hasMiddleware() method, and therefore does not support Laravel 5.0.

Install

Via Composer

Once composer has been updated and the package has been installed, the service provider will need to be loaded.

Laravel 5.5+, 6.x (5.5, 5.6, 5.7, 5.8, 6.x)

This package uses auto package discovery. The service provider will automatically be registered.

Laravel 5.1 - 5.4

Open config/app.php and add following line to the providers array:

Configuration

This package comes with a default configuration file that can be published in order to modify it.

This will publish the config file to config/cors.php. Modify this config file to change the default profile and to add new custom profiles.

Usage

Global Middleware

To apply a global CORS policy, add the \ShiftOneLabs\LaravelCors\Http\Middleware\ApplyCorsPolicy middleware to the global $middleware property in the app/Http/Kernel.php file. This global CORS policy will use whatever profile is defined as the default profile in the cors.php config file. By default, this is an open policy that will allow all CORS requests.

Route Middleware

To apply a route-specific CORS policy, first add a middleware alias for the policy middleware to the $routeMiddleware property in the app/Http/Kernel.php file.

Now you can add this middleware to any route or route group. Additionally, this route middleware can take a parameter to specify a CORS profile configuration defined in the cors.php config file.

Assume you add the following profile to the config file:

This new CORS profile can be applied to any route or route group using route middleware:

This route will now only allow CORS requests from example.com. A CORS request from any other origin will be rejected.

Multiple Middleware

It is possible for a request to have to pass through multiple defined policies. For example, if you have a global CORS policy, a group middleware policy, and a route specific policy, the request must pass the requirements for all three policies.

If the request fails, the response headers will be built using the first policy that failed, starting with the least specific (global) to the most specific (route).

If the request is successful, the response headers will be built using the last policy that the request went through.

Contributing

Contributions are welcome. Please see CONTRIBUTING for details.

Security

If you discover any security related issues, please email [email protected] instead of using the issue tracker.

Alternatives

Credits

License

The MIT License (MIT). Please see License File for more information.


All versions of laravel-cors with dependencies

PHP Build Version
Package Version
Requires php Version >=5.5.0
illuminate/config Version >=5.1
illuminate/container Version >=5.1
illuminate/contracts Version >=5.1
illuminate/http Version >=5.1
illuminate/routing Version >=5.1
illuminate/support Version >=5.1
laravel/framework Version >=5.1
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 shiftonelabs/laravel-cors contains the following files

Loading the files please wait ....