aalfiann / reverser
使用 PHP 反转您的实际后端。
1.1.0
2019-06-10 10:21 UTC
Requires
- php: >=5.6
This package is auto-updated.
Last update: 2024-09-10 23:00:05 UTC
README
使用 PHP 反转您的实际后端。
安装
通过 Composer 安装此包。
composer require "aalfiann/reverser:^1.0"
如何使用
创建新文件 index.php
use aalfiann\Reverser\Handler; require_once ('vendor/autoload.php'); $handler = new Handler('https://yourbackend.com:8080'); // Prevents cURL from hanging on errors $handler->setCurlOption(CURLOPT_CONNECTTIMEOUT, 1); $handler->setCurlOption(CURLOPT_TIMEOUT, 5); // This ignores HTTPS certificate verification, libcurl decided not to bundle ca certs anymore. // Alternatively, specify CURLOPT_CAINFO, or CURLOPT_CAPATH if you have access to your cert(s) $handler->setCurlOption(CURLOPT_SSL_VERIFYPEER, false); $handler->setCurlOption(CURLOPT_SSL_VERIFYHOST, false); // Check for a success if ($handler->execute()) { //print_r($handler->getCurlInfo()); // Uncomment to see request info } else { echo 'Oops, something went wrong!'; } // close handler $handler->close();
示例 Apache .htaccess
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-l [NC]
RewriteCond %{REQUEST_FILENAME} !-f [NC]
RewriteCond %{REQUEST_FILENAME} !-d [NC]
RewriteCond %{REQUEST_URI} !^/index.php
RewriteRule ^(.+)$ index.php/$1 [QSA]
注意
- 由于此包未包含 缓存,因此在高流量下不够强大。
- HTMLProxyHandler 类需要 Libcurl 中启用了 "https" 协议。