Contact Form

GitHub last commit CI Workflow GitHub code size in bytes GitHub Issues Total Downloads Monthly Downloads

Requirements

Thederafu/form and derafu/data-processor packages installed and configured in services.yaml.

Check the configuration in the website skeleton.

Quick Start

Install the package:

composer require derafu/contact-form --dev

Import the routes to your routes.yaml:

imports:
    - { resource: '../vendor/derafu/contact-form/resources/config/contact-form-routes.yaml' }

Import the services to your services.yaml:

imports:
    - { resource: '../vendor/derafu/contact-form/resources/config/contact-form-services.yaml' }

Copy the templates/contact/index.html.twig and templates/contact/success.html.twig to your project.

If you want to use the default templates (and not copy them), add the templates path to your service configuration:

Derafu\Renderer\Contract\RendererInterface:
    factory: ['Derafu\Renderer\Factory\RendererFactory', 'create']
    lazy: true
    arguments:
        $options:
            paths:
                - '%kernel.project_dir%/vendor/derafu/contact-form/resources/templates'

Configure the environment variables:

# Source of the form for identifying it in the webhook.
# Useful for multiple forms in the same webhook.
FORM_CONTACT_SOURCE=derafu.dev

# URL and secret key for processing the contact form.
# Get the URL from the webhook service you are using.
# The secret key will be used to sign the payload using HMAC.
FORM_CONTACT_WEBHOOK_URL=
FORM_CONTACT_WEBHOOK_SECRET_KEY=

# Site and secret key for protect forms with captcha.
# Get the keys from https://www.hcaptcha.com/
CAPTCHA_SITE_KEY=
CAPTCHA_SECRET_KEY=
On this page

#php
Last updated on 27/07/2025 by Anonymous