u/mccreaja

Double - a modern PHP mocking library focused on developer experience
▲ 58 r/PHP+1 crossposts

Double - a modern PHP mocking library focused on developer experience

After a few weeks of livestreaming the development process and dogfooding it in real projects, I'm excited to officially announce Double.

Double is a modern PHP mocking library focused on developer experience.

It stands on the shoulders of Mockery and RSpec. So there isn't much to learn. You get to enjoy a smoother DX.

A few things I wanted to improve:

  • Less technical terminology
  • Single, streamlined APIs
  • Human failure messages

With Double, you create a double for your class and write expectations. Double handles the details.

use JMac\Testing\Double;

$repository = Double::for(BookRepository::class);
$repository->expects('find')->with(123)->returns($book);

$service = new CatalogService($repository);
$service->lookup(123);

$repository->received('recordView')->with($book);

When an expectation fails, you get a proper test failure (not an exception). Along with a human-friendly message showing what actually happened and, where appropriate, a suggestion.

I also generated modern documentation with AI and ui.sh, where you may learn more about Double.

I've wanted to build this for years. So I'm all-in on Double. I've already converted all of my own test suites from Mockery to Double. I created a free Double Converter to automate the process.

This is still v0. While I believe it's already beyond feature parity with Mockery, I want to continue to improve the developer experience.

u/mccreaja — 9 days ago
▲ 13 r/PHP+1 crossposts

Bringing Test Impact Analysis to PHPUnit

Inspired by the new TIA Engine in Pest v5, I (and Claude) ported it to a PHPUnit extension.

As an extension, I can't hook into the actual test runner. So to achieve the same speed boost, it marks "unimpacted" test as skipped (S).

Hopefully this extension gains enough traction to be added to core and smooth out the developer experience.

For now, it achieves the goal of significantly improving test suite runs. I'm seeing my 1000 test drop from 2 minutes to 8 seconds on replay.

u/mccreaja — 16 days ago
▲ 10 r/laravel

AI review for Laravel upgrades with Shift

Since launching the AI prompts and AI skills, they've become my preferred way to use Shift. This has always been the biggest indicator for Shift - do I use it myself. AI helps push Shift's automation to the level I always wanted. It's the best of both worlds: deterministic changes from Shift and contextual changes from AI.

Last week, I launched the beta for an AI Review. This is available as an add-on to any of the Laravel upgrade Shifts. After your Shift runs, AI performs a second pass on your upgrade. It reads through Shift's detailed comments, understands the context of your codebase, and automates additional changes. Effectively performing many of the final review steps you would normally do after running your Shift.

As always, I welcome your feedback as I continue to refine this Shifts. I believe Shift + AI provides the most thorough and automated upgrade. So I'm excited to integrate the two even more.

reddit.com
u/mccreaja — 1 month ago
▲ 48 r/laravel

Making Laravel News fast!

Over the past few months, I've been working with Eric to make laravel-news.com more cacheable. This is the first site, in a series of case studies I want to do for Fast Laravel. Proving its page caching strategies can be used for more than just "brochure sites".

Here's the core changes we made to cache the top requested pages of Laravel News:

  1. Converted from Livewire to Blade Components. Livewire relies heavily on the session. As such, it's not readily cacheable. In the case of Laravel News, all but one of the components simply rendered. There was no reactivity.
  2. Add Alpine AJAX. For the few page segments that needed refresh, such as the newsletter form or sponsor card, we used Alpine AJAX. A few attributes and the proper AJAX calls were made to swap the placeholders with HTML responses.
  3. Automated cache purging. While it was easy to hook into events when articles or links were changed, some content is scheduled. For this, we scheduled a command to purge cached pages using the Cloudflare API.

There were some gotchas along the way. But these were the main technical changes. You may read the full article on Laravel News, or watch the interview on YouTube.

u/mccreaja — 2 months ago

Fully Automated Laravel Upgrades with Shift + AI

A quick demo of AI skills and commands that automate the entire Shift process right from your prompt - providing the most thorough, automated Laravel upgrade.

Follow the Shift AI README to install these skills and commands.

u/mccreaja — 3 months ago

In this video, I demo upgrading laravelshift.com to Laravel 13 using the new /upgrade skill and Shift. This highlights the best of both tools to provide the most thorough, automated upgrade.

tl;dw; The skill relies on AI. So no two runs are alike. Shift's goal is to make your application "look and feel" like it's been running Laravel 13. So its bar is higher. Using both provide the most thorough, automated upgraded.

Note: this video was clipped to meet Reddit's 15 minute time limit. You may watch the full video on YouTube to see me run the Livewire 4.x Shift and get everything passing.

u/mccreaja — 4 months ago