Zinq zinq

How to install Pest in an existing Laravel project

Posted on: March 18, 2025 by Matt

Pest is a modern and elegant testing framework for PHP, designed to be simple and enjoyable. If you're using Laravel and want to switch from PHPUnit to Pest, this guide will walk you through the installation process step by step.

# Steps to install Pest in a Laravel project

  1. Remove PHPUnit Since Laravel projects come with PHPUnit by default, we need to remove it first:
 
composer remove phpunit/phpunit
  1. Install Pest with Laravel Plugin Next, install Pest along with the Laravel plugin:
 
composer require pestphp/pest --dev --with-all-dependencies
composer require pestphp/pest-plugin-laravel --dev
  1. Initialize Pest Once installed, run the following command to generate the necessary Pest configuration files:
 
./vendor/bin/pest --init

# Conclusion

Switching to Pest in your Laravel project is straightforward and brings a more expressive and enjoyable testing experience. With its Laravel plugin, you can take full advantage of Laravel’s testing capabilities while keeping your test suite clean and readable.

If you haven't tried Pest yet, give it a shot! It might just become your favorite testing tool in PHP development.


Newsletter

Join other developers and never miss out on new tips, tutorials and Zinq updates!