paragonie/recaptcha
Composer 安装命令:
composer require paragonie/recaptcha
包简介
A fork of Google's PHP ReCAPTCHA Client with Proxy support.
关键字:
README 文档
README
This is a fork of Google's PHP ReCAPTCHA client that allows you to pass cURL options, e.g. to proxy requests over Tor.
$curl = new ReCaptcha\RequestMethod\CurlPost(null, array( CURLOPT_PROXY => 'http://127.0.0.1:9050/', CURLOPT_PROXYTYPE => CURLPROXY_SOCKS5 )); $recaptcha = new \ReCaptcha\ReCaptcha($secret, $curl); $resp = $recaptcha->verify($gRecaptchaResponse, $remoteIp); if ($resp->isSuccess()) { // verified! } else { $errors = $resp->getErrorCodes(); }
reCAPTCHA PHP client library
- Repository: https://github.com/paragonie/recaptcha
- Version: 2.1.0
- License: BSD, see LICENSE
Description
reCAPTCHA is a free CAPTCHA service that protect websites from spam and abuse. This is Google authored code that provides plugins for third-party integration with reCAPTCHA.
Installation
Composer (Recommended)
Composer is a widely used dependency manager for PHP
packages. This reCAPTCHA client is available on Packagist as
google/recaptcha and can be
installed either by running the composer require command or adding the library
to your composer.json. To enable Composer for you project, refer to the
project's Getting Started
documentation.
To add this dependency using the command, run the following from within your project directory:
composer require paragonie/recaptcha "~2.1"
Alternatively, add the dependency directly to your composer.json file:
"require": { "paragonie/recaptcha": "~2.1" }
Direct download (no Composer)
If you wish to install the library manually (i.e. without Composer), then you
can use the links on the main project page to either clone the repo or download
the ZIP file. For
convenience, an autoloader script is provided in src/autoload.php which you
can require into your script instead of Composer's vendor/autoload.php. For
example:
require('/path/to/recaptcha/src/autoload.php'); $recaptcha = new \ReCaptcha\ReCaptcha($secret);
The classes in the project are structured according to the PSR-4 standard, so you may of course also use your own autoloader or require the needed files directly in your code.
Development install
If you would like to contribute to this project or run the unit tests on within
your own environment you will need to install the development dependencies, in
this case that means PHPUnit. If you clone the repo and
run composer install from within the repo, this will also grab PHPUnit and all
its dependencies for you. If you only need the autoloader installed, then you
can always specify to Composer not to run in development mode, e.g. composer install --no-dev.
Note: These dependencies are only required for development, there's no requirement for them to be included in your production code.
Usage
First, register keys for your site at https://www.google.com/recaptcha/admin
When your app receives a form submission containing the g-recaptcha-response
field, you can verify it using:
<?php $recaptcha = new \ReCaptcha\ReCaptcha($secret); $resp = $recaptcha->verify($gRecaptchaResponse, $remoteIp); if ($resp->isSuccess()) { // verified! } else { $errors = $resp->getErrorCodes(); }
You can see an end-to-end working example in examples/example-captcha.php
Upgrading
From 1.0.0
The previous version of this client is still available on the 1.0.0 tag in
this repo but it is purely for
reference and will not receive any updates.
The major changes in 1.1.0 are:
- installation now via Composer;
- class loading also via Composer;
- classes now namespaced;
- old method call was
$rc->verifyResponse($remoteIp, $response), new call is$rc->verify($response, $remoteIp)
Contributing
We accept contributions via GitHub Pull Requests, but all contributors need to be covered by the standard Google Contributor License Agreement. You can find instructions for this in CONTRIBUTING
paragonie/recaptcha 适用场景与选型建议
paragonie/recaptcha 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 16.14k 次下载、GitHub Stars 达 6, 最近一次更新时间为 2016 年 03 月 27 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「recaptcha」 「proxy」 「spam」 「captcha」 「Abuse」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 paragonie/recaptcha 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 paragonie/recaptcha 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 paragonie/recaptcha 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Lazy loading for middleware and request handlers
Simple captcha generator
reCAPTCHA library
Client library for reCAPTCHA with proxy support, a free service that protects websites from spam and abuse.
Diese Contao 4 Erweiterung stellt Google reCAPTCHA V2 in Form eines neuen Formularfeldes im Formulargenerator bereit. This extension provides Google reCAPTCHA V2 in the form of a new form field in the form generator of Contao Open Source CMS.
A simple and easy to use Google ReCaptcha v3 package for Laravel
统计信息
- 总下载量: 16.14k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 7
- 点击次数: 31
- 依赖项目数: 2
- 推荐数: 0
其他信息
- 授权协议: BSD-3-Clause
- 更新时间: 2016-03-27