package

All my posts about package.

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

A clean API for reading PHP attributes original

by Freek Van der Herten – 3 minute read

PHP 8.0 introduced attributes, and they're a great way to add structured metadata to classes, methods, properties, constants, and parameters. The concept is solid, but the reflection API you need to actually read them is surprisingly verbose. What should be a simple one-liner ends up being multiple lines of boilerplate every time. And if you want to find all usages of an attribute across an entire class, you're looking at deeply nested loops.

We just released spatie/php-attribute-reader, a package that gives you a clean, static API for all of that. Let me walk you through what it can do.

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 Fuse: Circuit breaker for queue jobs

github.com

Laravel Fuse is a circuit breaker package for Laravel queue jobs. When an external service like Stripe or Mailgun goes down, instead of letting thousands of jobs timeout (30s each), the circuit opens after a configurable failure threshold and jobs fail instantly. It supports three-state circuit breaking (closed/open/half-open), intelligent failure classification (429s and auth errors do not trip the circuit), peak hours config, and a built-in status page.

Read more [github.com]