laravel

All my posts about laravel.

Laravel Site Search v3 is here: crawl and search your entire site using just your database original

by Freek Van der Herten – 5 minute read

We're proud to release v3 of laravel-site-search, a package that crawls and indexes your entire site. Think of it as your own private Google. Point it at a URL, let it crawl every page, and get full-text search results back.

Previous versions required Meilisearch as the search engine. That works well, but it means running a separate service.

With v3, your application's own database is all you need. It supports SQLite, MySQL, PostgreSQL, and MariaDB out of the box, and it's the new default.

Let me walk you through it.

Read more

How to easily access private properties and methods in PHP original

by Freek Van der Herten – 7 minute read

Sometimes you need to access a private property or method on an object that isn't yours. Maybe you're writing a test and need to assert some internal state. Maybe you're building a package that needs to reach into another object's internals. Whatever the reason, PHP's visibility rules are standing in your way.

Our spatie/invade package provides a tiny invade function that lets you read, write, and call private members on any object.

You probably shouldn't reach for this package often. It's most useful in tests or when you're building a package that needs to integrate deeply with objects you don't control.

Let me walk you through how it works.

Read more

Join 9,500+ smart developers

Get my monthly newsletter with what I learn from running Spatie, building Oh Dear, and maintaining 300+ open source packages. Practical takes on Laravel, PHP, and AI that you can actually use.

No spam. Unsubscribe anytime. You can also follow me on X.

Generate OG images for your Laravel app original

by Freek Van der Herten – 5 minute read

When you share a link on Twitter, Facebook, or LinkedIn, the platform shows a preview image. Getting those Open Graph images right usually means either using an external service or setting up a separate rendering pipeline. We just released laravel-og-image, a package that lets you define your OG image as HTML right inside your Blade views. The package takes a screenshot of that HTML and serves it as the OG image. No external API needed, everything runs on your own server.

Let me walk you through what the package can do.

Read more

Building a PHP CLI for humans and AI agents with almost no hand-written code original

by Freek Van der Herten – 6 minute read

We recently released the Flare CLI, a command-line tool to manage your errors and performance data. It also ships with an agent skill that lets AI coding agents use Flare on your behalf.

The CLI has dozens of commands and hundreds of options, yet we only wrote four commands by hand. Our laravel-openapi-cli package made this possible: point it at an OpenAPI spec, and it generates fully typed artisan commands for every endpoint automatically.

Here's how we put it all together.

Read more

Let your AI coding agent fix your errors and review performance original

by Freek Van der Herten – 4 minute read

The Flare CLI lets you manage errors and performance monitoring from the terminal. It was built with almost no hand-written code, generated from our OpenAPI spec. Having a CLI is useful on its own, but where it gets really interesting is when you let an AI coding agent use it.

The Flare CLI ships with an agent skill that teaches AI agents like Claude Code, Cursor, and Codex how to interact with Flare on your behalf. Let me show you how it works.

Read more

How to set up PHP autoformatting in Zed using Pint and PHP CS Fixer original

by Freek Van der Herten – 3 minute read

I only switched to Zed last week (you can see my full setup on my uses page), so I'm still learning the ropes. One thing I ran into is that its external formatter configuration is global. You configure one formatter command for PHP, and that's what gets used in every project you open.

The problem is that not all of my projects use the same formatter. Some use Pint, some use PHP-CS-Fixer directly. My Zed config originally pointed to ./vendor/bin/pint, which meant it silently did nothing in projects that don't have Pint installed.

Let me walk you through how I solved this.

Read more

Laravel Response Cache v8 is here: now offers flexible caching original

by Freek Van der Herten – 6 minute read

Our laravel-responsecache package speeds up your app by caching entire responses on the server. When the same page is requested again, the cached response is served without hitting your controller at all.

We just released v8, a new major version with a powerful new feature: flexible caching. It uses a stale-while-revalidate strategy, so that every visitor gets a fast response, even when the cache is being refreshed.

Let me walk you through it.

Read more

Laravel Permission v7 has been launched original

by Freek Van der Herten – 3 minute read

Laravel's built-in authorization is great when permissions are defined in code. With gates and policies, you can write logic like this:

// Defined in code, requires a deploy to change
Gate::define('edit-posts', function (User $user) {
    return $user->is_admin;
});

But in some projects roles and permissions are dynamic: created by users, managed through an admin panel, or changed at runtime without deploying code. Our Laravel Permission package can help you dynamically create roles and permissions.

We just released v7 which doesn't bring any new features, but cleans up the internal code and modernizes it. Let me walk you through what the package can do.

Read more