Download the PHP package recranet/craft-secure-forms without Composer

On this page you can find all versions of the php package recranet/craft-secure-forms. 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 craft-secure-forms

Secure Forms

Contact forms for Craft CMS 5 with spam protection, stored submissions and proper error reporting. Replaces craftcms/contact-form, hybridinteractive/craft-contact-form-extensions and recranet/craft-contact-form-recaptcha in one plugin.

Design principles

Features

Not supported

Deliberate non-goals, kept out to keep the attack surface and codebase small:

Installation

Usage

The individual fields are still available if you need to place them separately:

Why the action name matters

A reCAPTCHA v3 token is only as specific as the action it was minted with. When every form uses the same action, a token harvested from the cheapest form on the site — or from any other domain on the key's allowlist — verifies perfectly well against your most valuable form. Passing a distinct action per form (contact, apply, newsletter) binds each token to the form it came from: the action travels in a hashed hidden field, so the server compares Google's reported action against what the form actually rendered, and a bot cannot rewrite either side.

The plugin also compares the hostname Google reports against the hostname the form was posted to, which closes the same hole across domains sharing a site key.

Google only accepts letters, digits, / and _ in action names; anything else is logged as an error and falls back to submit.

Upgrading existing forms

Both checks are additive — a form that doesn't render the new fields keeps working exactly as before:

Form renders Timing check Action check Hostname check
fields('name') yes yes, per form yes
captcha() only (pre-1.6 template) skipped yes, against submit yes
nothing skipped n/a n/a

Once every form emits the timestamp, set requireTimestamp to true so a POST that never loaded a form is treated as spam.

Error handling in the template:

Configuration

All settings are read from the environment with sensible defaults, so one config file works across dev/staging/production. Create config/secure-forms.php:

When recaptchaHideBadge is enabled, Google requires the reCAPTCHA attribution to be visible in the form, e.g.:

Environment variables

Captcha keys live in .env:

Local dev: the boilerplate leaves the captcha keys empty so no captcha runs and the honeypot plus timing check still apply. If you do use Google's test keys locally, add testkey.google.com to SECURE_FORMS_CAPTCHA_ALLOWED_HOSTNAMES — that is the hostname Google reports for them.

All other settings can optionally be overridden per environment:

Google reCAPTCHA deprecation notes

Google deprecated classic reCAPTCHA and migrated all keys to Google Cloud projects (automated migration completed Q1 2026; keys without a Cloud project have API access locked). What this means for this plugin:

Migrating from contact-form-extensions

Stored submissions can be copied from craft-contact-form-extensions into Secure Forms. Run this before uninstalling the old plugin (its uninstall drops the source table):

Safe to re-run: already-migrated submissions are skipped. Recommended production order: install Secure Forms → run the migration → uninstall the old plugins.

Failure handling & manual delivery

Every submission is stored before any email is attempted, so nothing is ever lost. What happens per failure mode:

Failure Visitor sees Stored as Admin alert
Definite spam (honeypot hit, score below the reject threshold, submitted faster than minSubmitSeconds, missing/tampered timestamp) Success by default (spamAction: silent) Not stored — rejected outright Info log only
Gray-zone spam (score between reject and score thresholds, invalid/expired token, action or hostname mismatch) Success by default (spamAction: silent) spam + score/reason Reviewable in the Submissions index (spam is not an error)
Captcha misconfiguration (missing keys, domain not allowlisted, API unreachable, Enterprise quota) "Could not be verified" error failed + cause in sendError Nav badge + error log (Sentry when installed)
SMTP / transport failure "Could not be sent" error failed + cause in sendError Nav badge + error log (Sentry when installed)

Why an action/hostname mismatch is stored rather than rejected: when it fires for a real attack it fires occasionally, but when it fires because of a misconfiguration (a proxy rewriting the host, a stale cached page minting the old action, a site key shared across domains) it fires on every submission. Storing it means that shows up in the Submissions index instead of silently swallowing every message the site receives.

Nav badge: the Secure Forms item in the control panel sidebar shows a badge with the number of submissions whose notification email never went out — visible from every CP page, no email dependency (an email alert would be useless when SMTP is the thing that's down).

Manual delivery: the submission detail view has a send button that covers both cases — Retry sending for failed submissions, and Not spam — send for reviewed spam (delivering it marks it as not spam; the score and reason are kept for the record). Re-scoring is impossible by design: captcha tokens are single-use and expire within minutes, so a stored submission can never be re-verified — a human decision replaces the score.

Email templates

Site templates receive submission (the element) and message (the decoded dynamic fields):


All versions of craft-secure-forms with dependencies

PHP Build Version
Package Version
Requires php Version >=8.2
craftcms/cms Version ^5.0
guzzlehttp/guzzle Version ^7.2
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 recranet/craft-secure-forms contains the following files

Loading the files please wait ...