Download the PHP package yiisoft/yii-middleware without Composer
On this page you can find all versions of the php package yiisoft/yii-middleware. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download yiisoft/yii-middleware
More information about yiisoft/yii-middleware
Files in yiisoft/yii-middleware
Package yii-middleware
Short Description Yii Middleware
License BSD-3-Clause
Homepage https://www.yiiframework.com/
Informations about the package yii-middleware
Yii Middleware
The package provides middleware classes that implement PSR-15:
ForceSecureConnection
.HttpCache
.IpFilter
.Redirect
.Subfolder
.TagRequest
.Locale
.CorsAllowAll
.
For proxy related middleware, there is a separate package - Yii Proxy Middleware.
For more information on how to use middleware in the Yii Framework, see the Yii middleware guide.
Requirements
- PHP 8.0 or higher.
Installation
The package could be installed with Composer:
General usage
All classes are separate implementations of PSR 15 middleware and don't interact with each other in any way.
ForceSecureConnection
Redirects insecure requests from HTTP to HTTPS, and adds headers necessary to enhance the security policy.
The Content-Security-Policy
(CSP) header can force the browser to load page resources only through
a secure connection, even if links in the page layout are specified with an unprotected protocol.
Middleware adds HTTP Strict-Transport-Security (HSTS) header to each response. The header tells the browser that your site works with HTTPS only.
HttpCache
Implements client-side caching by utilizing the Last-Modified
and ETag
HTTP headers.
Additionally, you can specify the following options:
IpFilter
IpFilter
allows access from specified IP ranges only and responds with 403 for all other IPs.
Redirect
Generates and adds a Location
header to the response.
You can also set the status of the response code for redirection.
Subfolder
Supports routing when the entry point of the application isn't directly at the webroot. By default, it determines webroot based on server parameters.
Info: You should place this middleware before
Route
middleware in the middleware list.
If you want the application to run on the specified path, use the prefix instead:
TagRequest
Tags request with a random value that could be later used for identifying it.
Locale
Supports locale-based routing and configures URL generator.
Info: You should place this middleware before
Route
middleware in the middleware list.
The priority of lookup is the following:
- URI query path, that's
/de/blog
. - URI query parameter name, that's
/blog?_language=de
. You can customize parameter name viawithQueryParameterName()
. - Cookie named
_language
. You can customize name viawithCookieName()
. Accept-Language
header. Not enabled by default. UsewithDetectLocale(true)
to enable it.
Found locale is not saved by default. It can be saved to cookies:
To configure more services, such as translator or session, use SetLocaleEvent
(Yii Event Dispatcher is required).
Note: Using tranlator requires Yii Message Translator.
CorsAllowAll
Adds CORS headers to the response.
Documentation
- Internals
If you need help or have a question, the Yii Forum is a good place for that. You may also check out other Yii Community Resources.
License
The Yii Middleware is free software. It is released under the terms of the BSD License.
Please see LICENSE
for more information.
Maintained by Yii Software.
Support the project
Follow updates
All versions of yii-middleware with dependencies
psr/event-dispatcher Version ^1.0
psr/http-factory Version ^1.0
psr/log Version ^3.0
psr/http-message Version ^1.0|^2.0
psr/http-server-handler Version ^1.0
psr/http-server-middleware Version ^1.0
yiisoft/aliases Version ^3.0
yiisoft/cookies Version ^1.2
yiisoft/friendly-exception Version ^1.0
yiisoft/http Version ^1.2
yiisoft/network-utilities Version ^1.2
yiisoft/router Version ^3.0
yiisoft/session Version ^2.0
yiisoft/strings Version ^2.1
yiisoft/validator Version ^1.0|^2.0