定制 yii1tech/web 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

yii1tech/web

最新稳定版本:1.0.0

Composer 安装命令:

composer require yii1tech/web

包简介

Provides the enhanced components for the web request processing in Yii1 application

README 文档

README

The Enhanced Web Components Extension for Yii 1


This extension provides the enhanced components for the web request processing in Yii1 application.

For license information check the LICENSE-file.

Latest Stable Version Total Downloads Build Status

Installation

The preferred way to install this extension is through composer.

Either run

php composer.phar require --prefer-dist yii1tech/web

or add

"yii1tech/web": "*"

to the "require" section of your composer.json.

Usage

This extension provides the enhanced components for the web request processing in Yii1 application.

In particular, it allows correct and secure processing of the "forwarded" HTTP headers, which is crucial for distributed application with load balancer.

Application configuration example:

<?php

return [
    'components' => [
        'request' => [
            'class' => yii1tech\web\HttpRequest::class,
            'trustedHosts' => [
                '192.168.0.0/24', // trust "forwarded" headers coming from IP addresses in range `192.168.0.0-192.168.0.254`
            ],
        ],
    ],
    // ...
];

Usage example:

<?php

var_dump(Yii::app()->request->getRemoteIP()); // returns IP of current HTTP connection, e.g. load balancer, outputs '192.168.0.1'
var_dump(Yii::app()->request->getUserIp()); // returns user IP address, considering "forwarded" headers, outputs '162.55.123.243'
var_dump(Yii::app()->request->getUserHostAddress()); // alias of `getUserIp()`

统计信息

  • 总下载量: 2.23k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 3
  • 点击次数: 1
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 3
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: BSD-3-Clause
  • 更新时间: 2024-07-12