PHPackages                             mvlabs/zf2behat-extension - 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. [Testing &amp; Quality](/categories/testing)
4. /
5. mvlabs/zf2behat-extension

ActiveBehat-extension[Testing &amp; Quality](/categories/testing)

mvlabs/zf2behat-extension
=========================

Zend Framework 2 extension for Behat

0.5(12y ago)216.1k13[1 issues](https://github.com/mvlabs/zf2behat-extension/issues)MITPHPPHP &gt;=5.3.3

Since Jul 16Pushed 11y ago7 watchersCompare

[ Source](https://github.com/mvlabs/zf2behat-extension)[ Packagist](https://packagist.org/packages/mvlabs/zf2behat-extension)[ RSS](/packages/mvlabs-zf2behat-extension/feed)WikiDiscussions master Synced 4w ago

READMEChangelogDependencies (4)Versions (3)Used By (0)

[![](https://camo.githubusercontent.com/30a4394c9940781e3ba419b6ee7ad28cb92a984a206a345f6670cd450dedffb3/68747470733a2f2f7472617669732d63692e6f72672f6d766c6162732f7a663262656861742d657874656e73696f6e2e706e67)](https://camo.githubusercontent.com/30a4394c9940781e3ba419b6ee7ad28cb92a984a206a345f6670cd450dedffb3/68747470733a2f2f7472617669732d63692e6f72672f6d766c6162732f7a663262656861742d657874656e73696f6e2e706e67)

mvlabs/zf2behat-extension
=========================

[](#mvlabszf2behat-extension)

Behat extension for Zend Framework 2 inspired by Symfony2extension by [Konstantin Kudryashov](https://github.com/everzet).

Behat () is a php framework for Behavior Driven Development. This extension allows you to use it in your Zend Framework 2 projects. It initializes Behat, allowing you to quickly use your Gherking features within ZF2.

1.Requirements
==============

[](#1requirements)

This extension is installed through composer and has following dependencies:

```
"php":">=5.3.3",
"behat/behat":"=2.4@stable",
"zendframework/zendframework":">=2.2.0"

```

Composer will take care of installing these for you (see below).

2.Installation
==============

[](#2installation)

In order to install this extension, you only need to add the following in your Zend Framework 2 composer.json:

```
"require": {
     "mvlabs/zf2behat-extension" : "dev-master"
}

```

and then run composer.phar install (or update). At this point, you need to create a file named behat.yml in your application root folder with following content:

```
default:
 extensions:
    MvLabs\Zf2Extension\Zf2Extension:

```

3.Usage
=======

[](#3usage)

If you don't have an existing test suite, please proceed to 4.Initialization within a Module. Otherwise, you can use this extension within your existing test suite in 2 different ways:

1. If you are using php version 5.4+, you can use MvLabs\\Zf2BehatExtension\\Context\\Zf2Dictionary trait which provides basic ZendFramework 2 functionality. This functionality can only be used in one Context though.
2. You can implement the MvLabs\\Zf2BehatExtension\\Context\\Zf2AwareContextInterface for every context, avoiding to call parent context from subcontexts.

Both methods call a method setZf2App(Application $zf2Application) needed to set in a private property Zend\\Mvc\\Application to be reused on every step needed

4.Initialization inside a Module
================================

[](#4initialization-inside-a-module)

In order to initialize your feature suite inside a Zend Framework 2 module, you need to execute:

```
$ php bin\behat --init ""

```

So, for example, if you want to initialize the skeleton application, you could just do from your application root directory:

```
vendor/bin/behat --init Application

```

After the command is executed it will create a Features folder inside your module with a extension ready FeatureContext inside the Context subfolder. You should see following output in console:

```
+d module//src//Features - place your *.feature files here
+f module//src//Features/Context/FeatureContext.php - place your feature related code here

```

5.Running your features
=======================

[](#5running-your-features)

Now that you have your Features directory within your module source folder (module//src/) you can create your first feature file in Gherkin. Please refer to the official behat documentation ([http://docs.behat.org/quick\_intro.html#define-your-feature](http://docs.behat.org/quick_intro.html#define-your-feature)) to see how to create your first feature file.

At this point, you only need to run:

```
vendor/bin/behat

```

to run the feature against your module.

6.Feature profiles
==================

[](#6feature-profiles)

If you often find yourself running a specific module suite it's possible to set a module parameter inside a profile in your behat.yml file like in the example below:

```
default:
  extensions:
      MvLabs\Zf2Extension\Zf2Extension:
        module:

```

You can then just call behat without arguments:

```
vendor/bin/behat

```

Within a profile you can use a specific Zend Framework config/application.config.php file, through the following:

```
default:
  extensions:
      MvLabs\Zf2Extension\Zf2Extension:
        module:
	config:

```

7.Multiple feature profiles
===========================

[](#7multiple-feature-profiles)

You can also use multiple profiles, such in the example below:

```
default:
  extensions:
      MvLabs\Zf2Extension\Zf2Extension:
        module: User

example:
   extensions:
      MvLabs\Zf2Extension\Zf2Extension:
        module: Albums

```

After setting those profiles, you can your Albums module suite executing:

```
$ php bin\behat -p=example

```

8.Specific Feature Execution
============================

[](#8specific-feature-execution)

You can run specific features specifying file name:

```
$ php bin\behat ""

```

9.Appication Level Feature Suite
================================

[](#9appication-level-feature-suite)

If you don't want to use module-centric structure it's possible maitain an application structure specifing a features path and context class in your behat.yml file like in the example:

```
default:
  paths:
    features: features
  context:
      class: ModuleDemo\Features\Context\CustomContext

```

Using this path you shuold only remember to add your context class in the autoloader.

10.Configuration Parameters
===========================

[](#10configuration-parameters)

Supported options for profiles are:

1. module - set the module to be runned for a specific profile (only one module per profile is currently supported)
2. config - set a custom configuration file. if it is not specified config/application.config.php will be loaded

###  Health Score

32

—

LowBetter than 69% of packages

Maintenance19

Infrequent updates — may be unmaintained

Popularity32

Limited adoption so far

Community17

Small or concentrated contributor base

Maturity49

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 60% 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

Unknown

Total

1

Last Release

4731d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/4421796?v=4)[David Contavalli](/maintainers/mauipipe)[@mauipipe](https://github.com/mauipipe)

---

Top Contributors

[![mauipipe](https://avatars.githubusercontent.com/u/4421796?v=4)](https://github.com/mauipipe "mauipipe (18 commits)")[![maraspin](https://avatars.githubusercontent.com/u/242968?v=4)](https://github.com/maraspin "maraspin (6 commits)")[![siad007](https://avatars.githubusercontent.com/u/2149445?v=4)](https://github.com/siad007 "siad007 (6 commits)")

### Embed Badge

![Health badge](/badges/mvlabs-zf2behat-extension/health.svg)

```
[![Health](https://phpackages.com/badges/mvlabs-zf2behat-extension/health.svg)](https://phpackages.com/packages/mvlabs-zf2behat-extension)
```

###  Alternatives

[drupal/drupal-extension

Drupal extension for Behat

21115.5M166](/packages/drupal-drupal-extension)[friends-of-behat/symfony-extension

Integrates Behat with Symfony.

48024.5M632](/packages/friends-of-behat-symfony-extension)[friends-of-behat/variadic-extension

Variadic support for behat context arguments

2276.3M487](/packages/friends-of-behat-variadic-extension)[wp-cli/wp-cli-tests

WP-CLI testing framework

423.0M130](/packages/wp-cli-wp-cli-tests)[friends-of-behat/mink-extension

Mink extension for Behat

14035.9M553](/packages/friends-of-behat-mink-extension)[imbo/behat-api-extension

API extension for Behat

1092.6M9](/packages/imbo-behat-api-extension)

PHPackages © 2026

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