Wizard Component for Symfony2.




Installs: 3 952

Dependents: 0

Suggesters: 0

Security: 0

Stars: 36

Watchers: 15

Forks: 4

v1.2.0 2012-10-09 14:18 UTC

This package is not auto-updated.

Last update: 2024-06-08 10:14:09 UTC


Build Status

This is a simple component mainly developed for usage with the Symfony2 framework. And because of that there is some references to that. Which easily can be changed.


See LICENSE for licensing terms.


Everybody is welcome to send Pull Requests. But we reserve the right to reject any that is not in line with our goals for this component.

See for a list of contributors


There is 3 ways to install this component. You can use Composer, Phar or just include the code directly in your application.

Using phar

Theres is a ready to use phar achive in build/peytz-wizard.phar which includes its own small autoloader that automatically registers with php when included.


require 'phar://build/peytz-wizard.phar';


Using Composer

You can also install it via composer by using something like the following require.

    "require" : {
        "peytz/wizard" : "master-dev"

Running tests

$ phpunit


The api is very simple. You create a Report which properly should be an Doctrine Entity. The Report holds your data and must implement ReportInterface

A Report is required as a contructor argument for a Wizard. A Wizard should be subclassed to add custom steps or use a DependencyInjection framework to inject them into a Wizard object.

A Wizard holds a n number of Steps that implements the StepInterface. There is a basic Step implementation of StepInterface availible.


namespace Vendor\Wizard;

use Peytz\Wizard\Step;
use Vendor\Wizard\Form\CustomFormType;

class CustomStep extends Step
    public function getFormType()
        return new CustomFormType();

namespace Vendor\Wizard;

use Peytz\Wizard\Wizard;
use Peytz\Wizard\ReportInterface;
use Vendor\Wizard\CustomStep;

class CustomWizard extends Wizard
    public function __construct(ReportInterface $report)
        $this->add(new CustomStep());

namespace Vendor\Wizard;

use Peytz\Wizard\ReportInterface;

class Report implements ReportInterface

Controller action implementation using Symfony Validator component for validation. Validation Groups are extremely useful for this.


namespace Vendor\Wizard;

class Controller
    protected $validator;

    protected $wizard;

    public function myAction($stepIdentifier)
        $step = $this->wizard->get($stepIdentifier);
        $form = $this->createForm($step->getFormType(), $this->wizard->getReport(), array(
            'validation_groups' => array($step->getName()),

        if ($_POST) {
            if ($form->isValid()) {

                // You should proberly save some stuff here? And redirect

        return array(
            'form' => $form,

Sample Symfony2 DIC definition

I you want to use DependencyInjection with Symfony2 this is another way of having a Wizard and its steps associated.

The power of using a DIC is that each StepInterface implementation can have optional dependencies. Like building forms programmatically instead of having a FormType.

        <service id="vendor.wizard.custom" class="Peytz\Wizard\Wizard">
            <argument type="service" id="" />
            <call method="add">
                <argument type="service" id="vendor.wizard.custom.my_step" />

Updating gh-pages branch

$ ./
$ git push