Verzeichnisstruktur phpBB-3.3.16


Veröffentlicht
27.04.2026

So funktioniert es


Auf das letzte Element klicken. Dies geht jeweils ein Schritt zurück

Auf das Icon klicken, dies öffnet das Verzeichnis. Nochmal klicken schließt das Verzeichnis.
Auf den Verzeichnisnamen klicken, dies zeigt nur das Verzeichnis mit Inhalt an

      (Beispiel Datei-Icons)

Auf das Icon klicken um den Quellcode anzuzeigen

ARCHITECTURE.md

Zuletzt modifiziert: 01.05.2026, 11:26 - Dateigröße: 2.47 KiB


 01  # Architecture
 02   
 03  The general pattern of usage is to instantiate the `ReCaptcha` class with your
 04  secret key, specify any additional validation rules, and then call `verify()`
 05  with the reCAPTCHA response and user's IP address. For example:
 06   
 07  ```php
 08  <?php
 09  $recaptcha = new \ReCaptcha\ReCaptcha($secret);
 10  $resp = $recaptcha->setExpectedHostname('recaptcha-demo.appspot.com')
 11                    ->verify($gRecaptchaResponse, $remoteIp);
 12  if ($resp->isSuccess()) {
 13      // Verified!
 14  } else {
 15      $errors = $resp->getErrorCodes();
 16  }
 17  ```
 18   
 19  By default, this will use the
 20  [`stream_context_create()`](https://secure.php.net/stream_context_create) and
 21  [`file_get_contents()`](https://secure.php.net/file_get_contents) to make a POST
 22  request to the reCAPTCHA service. This is handled by the
 23  [`RequestMethod\Post`](./src/ReCaptcha/RequestMethod/Post.php) class.
 24   
 25  ## Alternate request methods
 26   
 27  You may need to use other methods for making requests in your environment. The
 28  [`ReCaptcha`](./src/ReCaptcha/ReCaptcha.php) class allows an optional
 29  [`RequestMethod`](./src/ReCaptcha/RequestMethod.php) instance to configure this.
 30  For example, if you want to use [cURL](https://secure.php.net/curl) instead you
 31  can do this:
 32   
 33  ```php
 34  <?php
 35  $recaptcha = new \ReCaptcha\ReCaptcha($secret, new \ReCaptcha\RequestMethod\CurlPost());
 36  ```
 37   
 38  Alternatively, you can also use a [socket](https://secure.php.net/fsockopen):
 39   
 40  ```php
 41  <?php
 42  $recaptcha = new \ReCaptcha\ReCaptcha($secret, new \ReCaptcha\RequestMethod\SocketPost());
 43  ```
 44   
 45  ## Adding new request methods
 46   
 47  Create a class that implements the
 48  [`RequestMethod`](./src/ReCaptcha/RequestMethod.php) interface. The convention
 49  is to name this class `RequestMethod\`_MethodType_`Post` and create a separate
 50  `RequestMethod\`_MethodType_ class that wraps just the calls to the network
 51  calls themselves. This means that the `RequestMethod\`_MethodType_`Post` can be
 52  unit tested by passing in a mock. Take a look at
 53  [`RequestMethod\CurlPost`](./src/ReCaptcha/RequestMethod/CurlPost.php) and
 54  [`RequestMethod\Curl`](./src/ReCaptcha/RequestMethod/Curl.php) with the matching
 55  [`RequestMethod/CurlPostTest`](./tests/ReCaptcha/RequestMethod/CurlPostTest.php)
 56  to see this pattern in action.
 57   
 58  ### Error conventions
 59   
 60  The client returns the response as provided by the reCAPTCHA services augmented
 61  with additional error codes based on the client's checks. When adding a new
 62  [`RequestMethod`](./src/ReCaptcha/RequestMethod.php) ensure that it returns the
 63  `ReCaptcha::E_CONNECTION_FAILED` and `ReCaptcha::E_BAD_RESPONSE` where
 64  appropriate.
 65