PHP code example of akyos / ux-forms

1. Go to this page and download the library: Download akyos/ux-forms library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

akyos / ux-forms example snippets


// config/bundles.php
Akyos\UXForms\UXFormsBundle::class => ['all' => true],

// src/Contract/ContactFormSubmissionHandlerInterface.php
public function handle(ContactForm $contactForm, array $values): void;

// src/Contact/MySubmissionHandler.php
namespace App\Contact;

use Akyos\UXForms\Contract\ContactFormSubmissionHandlerInterface;
use Akyos\UXForms\Entity\ContactForm;

final class MySubmissionHandler implements ContactFormSubmissionHandlerInterface
{
    public function handle(ContactForm $contactForm, array $values): void
    {
        // CRM, webhook, persistance custom…
    }
}

final class LoggingSubmissionHandler implements ContactFormSubmissionHandlerInterface
{
    public function __construct(
        private ContactFormSubmissionHandler $inner,
        private LoggerInterface $logger,
    ) {}

    public function handle(ContactForm $contactForm, array $values): void
    {
        $this->inner->handle($contactForm, $values);
        $this->logger->info('Contact form submitted', ['id' => $contactForm->getId()]);
    }
}

// Injection directe si besoin (CLI, listener…)
public function __construct(
    private ContactFormSubmissionService $submissionService,
) {}
yaml
# config/routes/ux_forms.yaml
ux_forms:
    resource: ../../vendor/akyos/ux-forms/config/routes.php
    type: php
    prefix: /admin
    name_prefix: admin_

# config/routes/ux_forms_public.yaml
ux_forms_public:
    resource: ../../vendor/akyos/ux-forms/config/routes_public.php
    type: php
bash
php bin/console doctrine:migrations:migrate

Visiteur submit
    → PublicForm (LiveComponent)
    → ContactFormSubmissionHandlerInterface::handle()
    → ContactFormSubmissionService::submit()
        1. Snapshot des champs en BDD (contact_form_submission)
        2. Envoi e-mail via ContactFormMailer
        3. Mise à jour du statut (sent / failed)

translations/contact_form.fr.yaml
translations/public_contact_form.fr.yaml
bash
# Tests unitaires du bundle
php vendor/bin/phpunit lib/ux-forms/tests/

# Tests d'intégration app hôte (exemple)
php vendor/bin/phpunit tests/Controller/Admin/UXForms/