Everything on PHP.
39 articles tagged PHP, sorted newest first.
Debug Faster with PHP 8.5 Fatal Error Backtraces
Before 8.5, a fatal timeout or out-of-memory error gave you one line and no path. PHP 8.5 prints the full stack trace by default — here's how it works.
Cache Per-Object Data Without Leaks Using PHP WeakMap
Caching data against an object in a plain array or SplObjectStorage quietly leaks memory in long-running workers. PHP's WeakMap lets the garbage collector reclaim those entries for you.
Persist Multi-Turn Chat History with the Laravel AI SDK
A stateless agent forgets every turn. Here's how to wire persistent conversation memory into a Laravel AI SDK agent, resume a chat by ID, and stop long histories from wrecking your token budget.
Parse HTML5 Properly with PHP 8.4's Dom\HTMLDocument
For twenty years, parsing HTML in PHP meant fighting DOMDocument's mangled UTF-8 and XPath. PHP 8.4's Dom\HTMLDocument finally does it properly.
Measure and Enforce Type Coverage with Pest's Type Coverage Plugin
'We use types' is not a measurable claim. Pest's type coverage plugin turns it into a percentage you can read per file and enforce in CI.
First-Class Callable Syntax for Cleaner Laravel Collection Pipelines
Turn any method into a Closure with a trailing (...) for cleaner Laravel collection pipelines — and dodge the map() arity trap that silently corrupts your output.
Duster: Run Pint, PHPStan, and Rector with One Command
A mature Laravel app ends up with four code-quality tools, four configs, and four CI steps. Here's how Duster collapses them into one command — and when that's actually worth it.
Catch Spelling Mistakes in Your Laravel Codebase with Peck
Typos harden into method names, routes, and API fields you can't rename without a breaking change. Here's how I wire Peck into a Laravel project to catch them before they ship.
PHP 8.4: Chain Methods on new Without the Extra Parentheses
PHP 8.4 drops the wrapper parentheses around new, so (new Foo())->bar() becomes new Foo()->bar(). Here's the one rule to remember and the precedence traps to avoid.
Laravel AI SDK Tool Calling: Let the Model Run Your PHP
Give a Laravel AI agent real abilities: typed PHP tools the model can call to look up data, with enum-constrained inputs and a hard cap on runaway loops.
Measure Test Quality, Not Just Coverage: Pest Mutation Testing
100% line coverage can still ship bugs. Here's how Pest's mutation testing finds the assertions your test suite is quietly missing.
Stop Looping: array_find, array_any and array_all in PHP 8.4
PHP 8.4 adds array_find, array_find_key, array_any and array_all — the readable way to search arrays and retire foreach-with-flag loops.
PHP 8.4 Lazy Objects: Defer Expensive Initialization in Laravel
You inject a heavy service into a controller, the container builds it on every request, and half your routes never touch it. PHP 8.4 lazy objects let you defer that cost until the object is actually used.
Deprecate Your Own Code with PHP 8.4's #[\Deprecated] Attribute
PHP 8.4's #[\Deprecated] attribute turns invisible docblock deprecations into real runtime warnings that reflection and static analysis can see. Here's how to use it in a Laravel package.
PHP 8.5 #[\NoDiscard]: Stop Silently Ignoring Return Values That Matter
PHP 8.5 ships a new #[\NoDiscard] attribute that warns when you forget to use a function's return value. Here is how to apply it to your own immutable builders — and why (void) is the only safe way to suppress it.
PHP 8.5 Asymmetric Visibility for Static Properties
PHP 8.5 finishes what 8.4 started: asymmetric visibility now applies to static properties. Read freely, write only from inside: and ditch the static getter boilerplate for good.
PHP Custom Attributes in Practice: Beyond Laravel's Built-ins
Laravel 13 ships dozens of built-in PHP attributes, but the docs are quiet on building your own. Here are the patterns I use in production for validation, auth, and auto-discovery.
Rector PHP: Automate Laravel Upgrade Refactors
Stop hand-editing hundreds of files when bumping PHP or Laravel versions. Here's how to wire Rector into a Laravel project, run it safely, and write a custom rule for the patterns specific to your codebase.
PHP Enum Methods and Interfaces: Beyond Basic Backed Enums
Most devs use PHP enums as glorified string constants. They can implement interfaces, carry methods, and replace entire class hierarchies: here's how.
PHP 8.5 Deprecations Cheat Sheet: What to Fix Before Upgrading
PHP 8.5 ships with a batch of deprecations that will become hard errors in PHP 9.0. Here's the complete list with one-line fixes and a Rector command to automate the scan.
PHPStan Level 10 in Laravel: Fix the 5 Most Common Errors
Bumped Larastan to level 10 and got 300 new errors? Here are the five patterns you'll see again and again: and the exact fix for each.
PHP 8.5 array_first and array_last: Clean Up Your Collection Fallbacks
PHP 8.5 adds two long-overdue functions that eliminate the awkward workarounds for accessing the first or last element of an array.
Laravel 13 PHP Attributes: Cleaner Models, Jobs, and Commands
Laravel 13 ships opt-in PHP attribute syntax across 36+ framework locations. Here's what changed for models, jobs, and Artisan commands: with zero migration required.
Dockerising Your Laravel App for Kubernetes: From Dockerfile to Running Pod
Take a Laravel app from Docker Compose to a running Kubernetes pod: covering the production Dockerfile, Nginx+PHP-FPM setup, and the K8s manifests you actually need.
Stop Using parse_url(): PHP 8.5's URI Extension Explained
PHP 8.5 ships a built-in URI extension that replaces parse_url() with immutable, type-safe objects. No third-party package needed.
PHP 8.5 clone with: Updating Readonly Objects Without Boilerplate
PHP 8.5 lets you pass an array to clone() to update properties in one expression. Here's how it replaces wither method boilerplate: and the gotchas you need to know first.
PHP 8.5 Pipe Operator: Clean Function Chaining in One Line
PHP 8.5's |> operator lets you chain functions left-to-right instead of nesting them inside-out. Here's how it works and where it breaks down.
Optimising Laravel Docker images with multi-stage builds
A single-stage Dockerfile for Laravel ends up with 800 MB+ images full of build tools you don't need in production. Multi-stage builds fix that: here's how.
Replacing String Constants with PHP Backed Enums in Laravel Models
String constants like STATUS_PENDING are typo-prone, unautocompleted, and impossible to enumerate exhaustively. PHP backed enums fix all of that: and Laravel has native support throughout.
PHP Readonly Classes as Value Objects in Laravel
Primitive obsession is one of those code smells that's easy to ignore: until you're debugging which integer is pounds and which is pence. PHP readonly classes fix that cleanly.
Upgrading from Livewire 3 to Livewire 4: A Practical Migration Guide
Livewire 4 shipped in early 2026 with SFCs, smarter wire:model, and a leaner Volt story. Here's how to upgrade a real app without surprises.
PHP 8.4 Fibers: Async Patterns Without a Framework
PHP has had Fibers since 8.1, and PHP 8.4 quietly improved them. You don't need ReactPHP or Amp to get useful concurrency patterns: here's what Fibers actually give you and when to reach for them.
Enforcing Laravel architecture rules with Pest's arch() helper
Pest's arch() helper lets you write rules that enforce your app's structure at test time: no more accidentally importing Eloquent into a controller.
Verifying Stripe webhook signatures in Laravel without Cashier
You don't need Laravel Cashier to verify Stripe webhook signatures. Here's the minimal setup using the Stripe PHP SDK directly in a controller.
The Complete Laravel Developer Toolchain for 2026
Stop spending days configuring tools. Here is every tool in my Laravel stack for 2026, why I chose each one, and exactly how to set it up.
Running Laravel Pint Automatically with Git Pre-Commit Hooks
CI failing because someone forgot to run Pint again. Here's how to wire up a Git pre-commit hook so it never slips through.
PHP 8.4 Property Hooks in Laravel Models
PHP 8.4 property hooks are a tidy language-level alternative to getters and setters: but before you reach for them in your Eloquent models, there's a catch worth understanding.
How to audit PHP dependencies (practical guide)
How to audit PHP Composer dependencies for security, license and maintenance issues, with tools and a small script you can run today.
Streamlining Laravel Developer Onboarding with a Makefile and Herd Pro
Speed up Laravel onboarding with a powerful Makefile. Automate Herd Pro setup, install dependencies, and seed databases for a consistent, one-command setup experience.