Download the PHP package mrpunyapal/nativephp-plugin-turnstile without Composer

On this page you can find all versions of the php package mrpunyapal/nativephp-plugin-turnstile. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package nativephp-plugin-turnstile

NativePHP Turnstile

Cloudflare Turnstile integration for Laravel backends used by NativePHP Mobile apps.

Installation

Set the Cloudflare keys in your Laravel backend:

Never put TURNSTILE_SECRET_KEY in the mobile app.

NativePHP v3 and v4

Turnstile is a browser widget, not a native mobile SDK. Both NativePHP Mobile v3 and v4 can use it through a WebView.

For v3, render Turnstile in the normal Blade/Livewire page displayed by the app.

For v4, SuperNative is the default application architecture, but the WebView component is still available. Put the Turnstile widget in the WebView portion of the screen.

The widget helper generates a self-contained HTML document:

Serve this HTML from an HTTPS hostname allowed by your Turnstile widget, then load that URL in a NativePHP WebView with JavaScript and DOM storage enabled. A hosted URL gives the challenge a real origin; do not rely on an opaque inline HTML origin. The document loads Cloudflare's Turnstile script from challenges.cloudflare.com.

On success the document emits a turnstile:success browser event containing the token. Expired, error, and timeout events are emitted as well. Generate the token immediately before the protected request.

For native URL-navigation callbacks, also pass a unique cdata state and a return_path pointing to a same-origin result endpoint. The widget navigates there with state and status in the query and the token only in the URL fragment. Validate the origin, result path, and state in the app. The API must still validate the token, expected hostname, action, and custom data with Siteverify. Reset the challenge after every submission attempt.

Laravel API example

The mobile app should send the token to your Laravel API, not the Cloudflare secret:

Cloudflare's response includes the result, challenge timestamp, hostname, action, custom data, and error codes. Failed verification responses are returned normally so the API can decide how to respond. Network failures and invalid configuration/input throw TurnstileException.

Security

A successful browser callback is not proof that the request is valid. The Laravel backend must call Cloudflare Siteverify.

Turnstile tokens are short-lived and single-use. Do not store them for later requests. A timeout-or-duplicate response means the client should obtain a fresh token.

For mobile authentication or account creation, keep your normal API authentication, authorization, rate limiting, and server-side validation in place. Turnstile is an additional bot check, not a replacement for those controls.

Testing

Run:

Cloudflare provides test keys for CI and local automated testing.


All versions of nativephp-plugin-turnstile with dependencies

PHP Build Version
Package Version
Requires php Version ^8.2
guzzlehttp/guzzle Version ^7.0|^8.0
illuminate/contracts Version ^11.0|^12.0|^13.0
illuminate/support Version ^11.0|^12.0|^13.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package mrpunyapal/nativephp-plugin-turnstile contains the following files

Loading the files please wait ...