承接 redirectionio/proxy-sdk 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

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

redirectionio/proxy-sdk

最新稳定版本:v0.4.0

Composer 安装命令:

composer require redirectionio/proxy-sdk

包简介

PHP common code for redirection.io proxy

README 文档

README

[DEPRECATED]: This library is deprecated and will not be maintained anymore. It does not work with the current version of the redirection.io agent, but only with the legacy 1.x branch. We advise you to migrate and use one of the recommended integrations.

redirection.io is a tool to track HTTP errors and setup useful HTTP redirections. It listens your website's HTTP traffic and logs every HTTP errors, so you can check that the project's redirection rules apply efficiently.

Quick demo (see below for detailed info):

$client = new RedirectionIO\Client\Sdk\Client($projectKey, $connections); $request = new RedirectionIO\Client\Sdk\HttpMessage\Request( $_SERVER['HTTP_HOST'], $_SERVER['REQUEST_URI'], $_SERVER['HTTP_USER_AGENT'], $_SERVER['HTTP_REFERER'] ); $response = $client->request(new RedirectionIO\Client\Sdk\Command\MatchWithResponseCommand($request)); // There are no redirection for this Request if (null === $response) { $response = '...'; // Handle your request with your application } $client->request(new RedirectionIO\Client\Sdk\Command\LogCommand($request, $response)); // Finally, Returns your response

Requirements

Installation

To use redirection.io in your project, add it to your composer.json file:

$ composer require redirectionio/proxy-sdk 

Usage

Instantiate Client

Before starting, you need to instantiate a new Client.

use RedirectionIO\Client\Sdk\Client; $client = new Client(string $projectKey, array $connections, int $timeout = 10000, bool $debug = false, LoggerInterface $logger = null);

Parameters:

  • $projectKey your project key (can be found in redirection.io dashboard)
    $projectKey = 'szio2389-bfdz-51e8-8468-02dcop129501:ep6a4805-eo6z-dzo6-aeb0-8c1lbmo40242';
  • $connections array of connection(s) parameters to the Agent(s)
    $connections = [ 'connection_tcp' => 'tcp://127.0.0.1:10301', 'connection_unix' => 'unix:///var/run/redirectionio_agent.sock', ];
  • $timeout timeout in microsecond for connection/request;
  • $debug enable or disable debug mode. In debug mode an exception is thrown is something goes wrong, if not every errors is silenced;
  • \Psr\Log\LoggerInterface $logger A logger.

Find if a redirection rule exists

Check if request URI matches a redirect rule in the agent. If yes return a RedirectResponse, else return null.

use RedirectionIO\Client\Sdk\Client; use RedirectionIO\Client\Sdk\HttpMessage\Request; use RedirectionIO\Client\Sdk\Command\MatchCommand; $client->request(new MatchWithResponseCommand(Request $request);

Parameter:

  • \RedirectionIO\Client\Sdk\HttpMessage\Request $request.

Return values:

  • \RedirectionIO\Client\Sdk\HttpMessage\RedirectResponse $response if agent has found a redirect rule for the current request uri;
  • null if there isn't redirect rule set for the current uri in the agent.

Find if a redirection rule exists for old agent (<1.4.0)

Check if request URI matches a redirect rule in the agent. If yes return a RedirectResponse, else return null.

This will also return null if the rule should have been matched against a Response Status Code. This is mainly for BC Compatibility and avoid old proxy to handle rules that it should not.

use RedirectionIO\Client\Sdk\Client; use RedirectionIO\Client\Sdk\HttpMessage\Request; use RedirectionIO\Client\Sdk\Command\MatchCommand; $client->request(new MatchCommand(Request $request);

Parameter:

  • \RedirectionIO\Client\Sdk\HttpMessage\Request $request.

Return values:

  • \RedirectionIO\Client\Sdk\HttpMessage\RedirectResponse $response if agent has found a redirect rule for the current request uri;
  • null if there isn't redirect rule set for the current uri in the agent.

Log a request/response couple

Allow you to log a request/response couple for every request.

use RedirectionIO\Client\Sdk\Client; use RedirectionIO\Client\Sdk\Command\LogCommand; use RedirectionIO\Client\Sdk\HttpMessage\Response; use RedirectionIO\Client\Sdk\HttpMessage\Request; $client->request(new LogCommand(Request $request, Response $response));

Parameters:

  • \RedirectionIO\Client\Sdk\HttpMessage\Response $request
  • \RedirectionIO\Client\Sdk\HttpMessage\Request $response

Return value:

  • bool is true if log has been successfully added, else false

Contribution

We take care of all new PRs. Any contribution is welcome :) Thanks.

Install

$ composer install 

Run tests

$ composer test 

统计信息

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

GitHub 信息

  • Stars: 7
  • Watchers: 5
  • Forks: 1
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-01-04

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固