Write Better Laravel Tests with Pest PHP
Pest PHP makes Laravel testing more expressive and less boilerplate-heavy. This tutorial walks through installation, expectations, datasets, higher-order tests, and architecture rules.
If you have ever looked at a wall of PHPUnit boilerplate and thought "there has to be a better way," there is. Pest PHP is a testing framework built on top of PHPUnit that gives you a more expressive, less ceremonious syntax for writing tests — and it ships as the default testing framework in new Laravel applications. This tutorial covers Pest from installation through the features that make it genuinely worth using over plain PHPUnit. Installation New Laravel projects include Pest by default. For existing projects, install it and run the migration command: composer require pestphp/pest --dev composer require pestphp/pest-plugin-laravel --dev ./vendor/bin/pest --init Run your tests with: php artisan test # or ./vendor/bin/pest The Basic Syntax In PHPUnit, every test is a class with a method. In Pest, a test is a function call: // PHPUnit class UserTest extends TestCase { public function test_a_user_can_be_created(): void { $user = User::factory()->create(); $this->assertInstanceOf(User...
Pest PHP makes Laravel testing more expressive and less boilerplate-heavy. This tutorial walks through installation, expectations, datasets, higher-order tests, and architecture rules.
Laravel Sanctum handles both SPA cookie authentication and API token auth in one lightweight package. This tutorial covers both approaches, token abilities, expiration, and mobile auth.
The laravel/mcp package lets you expose your application as a structured MCP server so AI clients like Claude, Cursor, and GitHub Copilot can query your actual data instead of guessing at it.
Middleware in Laravel goes well beyond authentication guards. These five techniques cover terminable middleware, priority ordering, route-level parameters, and more.
PHP 8.4 shipped property hooks, asymmetric visibility, and more. Here is what each feature means for your day-to-day Laravel code and how to start using them now.
These five underused Eloquent features will help you write less code, run fewer queries, and make your models a lot more pleasant to work with.
Nuno Maduro just shipped Moat, a free Rust-powered CLI that scans your GitHub account, org, or repo and gives your security posture a hard look. Here is what it checks and why you should care.