PHPackages                             lexal/http-stepped-form - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [HTTP &amp; Networking](/categories/http)
4. /
5. lexal/http-stepped-form

ActiveLibrary[HTTP &amp; Networking](/categories/http)

lexal/http-stepped-form
=======================

HTTP based Stepped Form.

v4.0.1(1mo ago)11.1k1MITPHPPHP &gt;=8.1CI passing

Since Jan 16Pushed 1mo ago1 watchersCompare

[ Source](https://github.com/lexalium/http-stepped-form)[ Packagist](https://packagist.org/packages/lexal/http-stepped-form)[ RSS](/packages/lexal-http-stepped-form/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (9)Dependencies (16)Versions (11)Used By (1)

HTTP based Stepped Form
=======================

[](#http-based-stepped-form)

[![PHPUnit, PHPCS, PHPStan Tests](https://github.com/lexalium/http-stepped-form/actions/workflows/tests.yml/badge.svg)](https://github.com/lexalium/http-stepped-form/actions/workflows/tests.yml)

The package is based on the [Stepped Form package](https://github.com/lexalium/stepped-form) and works with HTTP response and request (transforms form exception into Response and renders or redirects depending on base form return value).

Table of Contents

1. [Requirements](#requirements)
2. [Installation](#installation)
3. [Usage](#usage)
    - [Exception Normalizers](#exception-normalizers)
4. [License](#license)

---

Requirements
------------

[](#requirements)

**PHP:** &gt;=8.1

Installation
------------

[](#installation)

Via Composer

```
composer require lexal/http-stepped-form

```

Usage
-----

[](#usage)

1. Create a base [Stepped Form](https://github.com/lexalium/stepped-form).
2. Declare your form settings.

    ```
    use Lexal\HttpSteppedForm\Settings\FormSettingsInterface;
    use Lexal\SteppedForm\Step\StepKey;

    final class FormSettings implements FormSettingsInterface
    {
        public function getStepUrl(StepKey $key): string
        {
            // return step URL
        }

        public function getUrlBeforeStart(): string
        {
            // returns a URL to redirect to when there is no renderable step
        }

        public function getUrlAfterFinish(): string
        {
            // return a URL to redirect to when the form is finished
        }
    }

    $formSettings = new FormSettings();
    ```
3. Create a Redirector. The Redirector creates and returns Redirect Response.

    ```
    use Lexal\HttpSteppedForm\Routing\RedirectorInterface;
    use Symfony\Component\HttpFoundation\Response;

    final class Redirector implements RedirectorInterface
    {
        public function redirect(string $url, array $errors = []): Response
        {
            // create and return redirect response
        }
    }

    $redirector = new Redirector();
    ```
4. Create a Renderer. The Renderer creates and returns Response by template definition.

    ```
    use Lexal\HttpSteppedForm\Renderer\RendererInterface;
    use Lexal\SteppedForm\Entity\TemplateDefinition;
    use Symfony\Component\HttpFoundation\Response;

    final class Renderer implements RendererInterface
    {
        public function render(TemplateDefinition $definition): Response
        {
            // create and return response
        }
    }

    $renderer = new Renderer();
    ```
5. Create an Exception Normalizer.

    ```
    use Lexal\HttpSteppedForm\ExceptionNormalizer\ExceptionNormalizer;
    use Lexal\HttpSteppedForm\ExceptionNormalizer\Normalizers\AlreadyStartedExceptionNormalizer;
    use Lexal\HttpSteppedForm\ExceptionNormalizer\Normalizers\DefaultExceptionNormalizer;
    use Lexal\HttpSteppedForm\ExceptionNormalizer\Normalizers\EntityNotFoundExceptionNormalizer;
    use Lexal\HttpSteppedForm\ExceptionNormalizer\Normalizers\FormNotStartedExceptionNormalizer;
    use Lexal\HttpSteppedForm\ExceptionNormalizer\Normalizers\StepNotFoundExceptionNormalizer;
    use Lexal\HttpSteppedForm\ExceptionNormalizer\Normalizers\StepNotRenderableExceptionNormalizer;

    $normalizer = new ExceptionNormalizer([
        new AlreadyStartedExceptionNormalizer($redirector),
        new EntityNotFoundExceptionNormalizer($redirector),
        new FormNotStartedExceptionNormalizer($redirector),
        new StepNotRenderableExceptionNormalizer(),
        new StepNotFoundExceptionNormalizer(),
        new DefaultExceptionNormalizer(),
    ]);
    ```
6. Create a Stepped Form.

    ```
    use Lexal\HttpSteppedForm\SteppedForm;

    $form = new SteppedForm(
        /* a base stepped form from the step 1 */,
        $formSettings,
        $redirector,
        $renderer,
        $normalizer,
    );
    ```
7. Use Stepped Form in your application.

    ```
    /*
     * Starts a new form session.
     * Returns redirect response to the next step or URL after form finish.
     */
    $form->start(
        /* an entity to initialize a form state */,
        /* unique session key if you need to split different sessions of one form */,
    );

    /* Renders step by its definition */
    $form->render('key');

    /*
     * Handles a step logic and saves a new form state.
     * Returns redirect response to the next step or URL after form finish.
     */
    $form->handle('key', /* request instance*/);

    /* Cancels form session and returns redirect response to the given URL */
    $form->cancel(/* any URL */);
    ```

([back to top](#readme-top))

Exception Normalizers
---------------------

[](#exception-normalizers)

Exception Normalizers are used for normalizing Stepped Form exceptions into the Response instance. Create class that implements `ExceptionNormalizerInterface` to have your own exception normalizer.

```
use Lexal\HttpSteppedForm\Settings\FormSettingsInterface;
use Lexal\HttpSteppedForm\ExceptionNormalizer\ExceptionNormalizerInterface;
use Lexal\SteppedForm\Exception\AlreadyStartedException;
use Lexal\SteppedForm\Exception\SteppedFormException;
use Symfony\Component\HttpFoundation\Response;

final class CustomExceptionNormalizer implements ExceptionNormalizerInterface
{
    public function supportsNormalization(SteppedFormException $exception): bool
    {
        return $exception instanceof AlreadyStartedException;
    }

    public function normalize(SteppedFormException $exception, FormSettingsInterface $formSettings): Response
    {
        // return custom response object
        return new Response();
    }
}
```

The package already contains normalizers for all available exceptions:

1. `AlreadyStartedExceptionNormalizer` - redirects to the current renderable step.
2. `EntityNotFoundExceptionNormalizer` - redirects with errors to the previously renderable step or the URL before form start.
3. `FormNotStartedExceptionNormalizer` - redirects with errors to the URL before form start.
4. `StepNotFoundExceptionNormalizer` - returns 404 HTTP status code.
5. `StepNotRenderableExceptionNormalizer` - returns 404 HTTP status code.
6. `SteppedFormErrorsExceptionNormalizer` - redirects with errors to the previously renderable step or the URL before form start.
7. `StepNotSubmittedExceptionNormalizer` - redirects with errors to the previously renderable step or the URL before form start.
8. `DefaultExceptionNormalizer` - rethrows exception.

([back to top](#readme-top))

---

License
-------

[](#license)

HTTP Stepped Form is licensed under the MIT License. See [LICENSE](LICENSE) for the full license text.

###  Health Score

50

—

FairBetter than 95% of packages

Maintenance92

Actively maintained with recent releases

Popularity20

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity64

Established project with proven stability

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~170 days

Recently: every ~199 days

Total

10

Last Release

40d ago

Major Versions

v1.1.1 → v2.0.02023-12-17

v2.1.0 → v3.0.02024-01-23

v3.0.1 → v4.0.02025-07-06

PHP version history (2 changes)v1.0.0PHP ^8.0

v2.0.0PHP &gt;=8.1

### Community

Maintainers

![](https://www.gravatar.com/avatar/e58c7184c9ec2cebd6c37bb1fbc98870dc0f43abeccc4f0c873edf364a11c321?d=identicon)[alexxxkk](/maintainers/alexxxkk)

---

Top Contributors

[![lexalium](https://avatars.githubusercontent.com/u/28488207?v=4)](https://github.com/lexalium "lexalium (16 commits)")

---

Tags

httpmulti-step-formstepped-formhttp multi-step form

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Type Coverage Yes

### Embed Badge

![Health badge](/badges/lexal-http-stepped-form/health.svg)

```
[![Health](https://phpackages.com/badges/lexal-http-stepped-form/health.svg)](https://phpackages.com/packages/lexal-http-stepped-form)
```

###  Alternatives

[symfony/psr-http-message-bridge

PSR HTTP message bridge

1.3k296.6M804](/packages/symfony-psr-http-message-bridge)[friendsofsymfony/http-cache-bundle

Set path based HTTP cache headers and send invalidation requests to your HTTP cache

43813.2M47](/packages/friendsofsymfony-http-cache-bundle)[api-platform/http-cache

API Platform HttpCache component

223.2M7](/packages/api-platform-http-cache)[swoole-bundle/swoole-bundle

Open/Swoole Symfony Bundle

6650.4k](/packages/swoole-bundle-swoole-bundle)[yosymfony/httpserver

A simple HTTP server

1940.1k1](/packages/yosymfony-httpserver)[zeroem/curl-bundle

Allows you to easily create and execute HTTP Requests with cURL

1323.5k](/packages/zeroem-curl-bundle)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
