Download the PHP package kafkiansky/symfony-middleware without Composer

On this page you can find all versions of the php package kafkiansky/symfony-middleware. 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 symfony-middleware

PSR-15 middleware now in Symfony

test Codecov Total Downloads Quality Score

Contents

Installation

Configuration

Ensure you have added bundle in config/bundles.php:

Create the configuration file in packages/symiddleware.yaml:

Usage

Each middleware must implement the Psr\Http\Server\MiddlewareInterface interface. Thanks for symfony autoconfiguration now the middleware registry knows your middleware.

So that middlewares can start execution, they must be defined on controller class and/or on controller method.

If controller is invokable, middleware can be defined just on controller class:

groups

If you want to use the list of middlewares, you can define middleware group inside symfony_middleware.yaml configuration file:

Now define this middleware on controller class or method:

Pay attention to the if parameter in configuration file. This parameter tells the middleware runner when the middleware group can be run. If false, this middleware will not be executed.

global

If you want to run the list of middleware every request, you need the global middleware section. This keyword is reserved and if parameter is not supported.

Now the App\Controller\SetCorsHeaders middleware will execute on every request.

Examples

  1. Simple middleware that modifies request:

  2. Middleware that modifies response:

  3. Middleware that stop execution:

In this example controller will not be executed.

  1. Stop execution with symfony response:

You can compose middleware group with single middleware, use list of Middleware attributes and so on. All the following examples will work:

Also, you can use nested groups:

Duplicated middlewares will be removed.

Customization

PSR middlewares and Symfony has different incompatible Request objects. If your middleware going to change the request object, only attributes, query params, headers and parsed body will be copied from psr request to symfony request. If you wish to change this behaviour, you may change the Kafkiansky\SymfonyMiddleware\Psr\PsrRequestCloner interface binding it to your realization.

Caching

Package use caching on production environment to prevent reflection usage. First of all, package will search of the app.cache_middleware parameter. If package doesn't find it, it's going to use the kernel.environment definition and will cache attributes when it set to prod.

Package will cache all controllers even if it doesn't found the attributes for it. This approach will allow to remember all the controllers and not use reflection further.

Real World Example

Imagine that you have some endpoints which requires authorization access via basic. Write middleware:

Middlewares

Handle HTTP Basic Auth PSR-15 middleware for Symfony

Testing

License

The MIT License (MIT). See License File for more information.


All versions of symfony-middleware with dependencies

PHP Build Version
Package Version
Requires php Version ^8.2
symfony/dependency-injection Version ^7.0
symfony/event-dispatcher Version ^7.0
symfony/http-kernel Version ^7.0
symfony/config Version ^7.0
symfony/http-foundation Version ^7.0
psr/http-server-middleware Version ^1.0
psr/http-server-handler Version ^1.0
symfony/psr-http-message-bridge Version ^7.0
nyholm/psr7 Version ^1.4
symfony/cache Version ^7.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 kafkiansky/symfony-middleware contains the following files

Loading the files please wait ....