定制 dynoser/proxier 二次开发

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

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

dynoser/proxier

最新稳定版本:1.0.1

Composer 安装命令:

composer require dynoser/proxier

包简介

Performs an HTTP request by copying the original request headers and replacing some of them

README 文档

README

Introduction

The Proxier class is designed to work as a proxy for web requests.

Optional features:

  • replace any headers from original request to specified
  • cache responses with code 200 for the specified time (default 3600 seconds)

Requirements

  • PHP 5.6 or higher.
  • cURL extension enabled.

Installation

All code is in one src/Proxier.php file, you may include only this file.

or, you may use composer require dynoser/proxier

or, include the package in your composer.json file and run composer update.

Features

  • URL and Header Manipulation: Allows encoding and decoding of URLs and request headers using Base64url.
  • Caching Mechanism: (optional) Caches successful responses (code 200) for a specified duration.

Usage

To use this class, you need to create a file accessible via the web with code approximately like this:

// (optional) specify directory for cache. if the cacheBaseDir is not specified, it will work without caching
$cacheBaseDir = "[YOUR ROOT PATH]/cache/proxier";

// load Proxier class without autoload, or use 'vendor/autoload.php' instead
$chkFile = "[YOUR ROOT PATH]/vendor/dynoser/proxier/src/Proxier.php";
require  $chkFile;

// required: create object and setup parameters: url, rep, cachesec.
// Only the URL is required, other parameters are optional.
$p = new \dynoser\webtools\Proxier($_REQUEST['url'] ?? '', $_REQUEST['rep'] ?? '', $_REQUEST['cachesec'] ?? '');

// (optional)
if (!empty($cacheBaseDir)) {
    $p->setCacheBaseDir($cacheBaseDir, true);
}

// run required
$p->run();

// remove old-cache-data periodicaly
//   (or you may call this fuction by cron instead)
$p->removeCachePeriodically();

Remote call:

In order to use a proxy request, you can insert something like the following code when creating a web page:

        $urlB64 = Proxier::makeUrlPar($url);

        echo '<img src="[URL WHERE PLACED YOUR SCRIPT]/proxier.php?' . $urlB64 . '" />';

Contribution

Feel free to contribute or suggest improvements via GitHub.

License

This class is open-sourced software licensed under the MIT license.

Support

For issues and features requests, please file an issue on the GitHub repository.

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: Apache-2.0
  • 更新时间: 2023-12-02