定制 madeorsk/forwarded 二次开发

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

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

madeorsk/forwarded

最新稳定版本:1.0.1

Composer 安装命令:

composer require madeorsk/forwarded

包简介

Forwarded header (RFC 7239) parsing library for PHP.

README 文档

README

Forwarded is a PHP library which parse the Forwarded request header as defined in RFC 7239. The Forwarded header is a standardized method for identifying the originating IP address of a client connecting to a web server through an HTTP proxy or load balancer, for example.

Forwarded is distributed as a composer library.

Getting started

Just add the dependency to your composer project:

composer require madeorsk/forwarded

How to use

The easy way

Usually, you just want to get the Forwarded header from your current request (for example when using PHP-FPM), or even just the IP address of the origin of the request.

<?php

use Madeorsk\Forwarded\Forwarded;

$forwarded = Forwarded::get(); // Getting the parsed Forwarded header.

$originIp = Forwarded::getOriginIp(); // Getting the IP address of the origin request from the parsed Forwarded header.

If you need more control

If you cannot obtain the header content from the classic standard way, you can call directly the Forwarded header parser.

<?php

use Madeorsk\Forwarded\Parser;

// Get a Forwarded parsed header from its raw string.
$forwarded = (new Parser())->parse("for=192.0.2.43,for=\"[2001:db8:cafe::17]\",for=unknown");

// Get the Forwarded header content parsed in a raw associative array from its raw string.
$forwardedAssoc = (new Parser())->parseAssoc("for=192.0.2.43,for=\"[2001:db8:cafe::17]\",for=unknown");

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2023-05-26

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固