Extremly simple Laravel Behat extension

v1.0.2 2020-12-03 20:14 UTC

This package is auto-updated.

Last update: 2021-01-03 20:17:23 UTC


Latest Stable Version Total Downloads License

Larahat extension is an extremely simple way to start behaviour-driven development with Laravel framework and Behat.


Just use composer, it will add required classes to your vendor directory at Larahat namespace:

composer require krzysztofrewak/larahat --dev


Locate your Behat configuration file (usually it's a behat.yml) and add Larahat\BehatExtension to your extensions list. You can also provide a custom .env filename via env variable, but by default it will be always .env.behat.

      env: ".env.behat"

From now, in your context files you are able to use app() helper for retrieving your bootstrapped Laravel application. For example, you can handle requests directly into your application like that:

 * @When :method request is sent to :endpoint endpoint
 * @param string $method
 * @param string $endpoint
public function requestIsSentToEndpoint(string $method, string $endpoint): void
    $request = Request::create($endpoint, $method);


  • KrzysztofRewak\Larahat\Helpers\DisablingThrottling trait added to your context helps with disabling throttling middleware;
  • KrzysztofRewak\Larahat\Helpers\RefreshDatabase trait added to your context helps with refreshing database with every scenario;
  • KrzysztofRewak\Larahat\Helpers\SimpleRequesting trait added to your context helps with sending requests and receiving responses from your application.


You can use Composer in a container if you want to:

docker-compose run -w /application -u "$(id -u):$(id -g)" composer install