Overview
This section covers topics that go beyond the official documentation — areas where you need to read the framework source code to fully understand what’s happening. It also serves as a resource for package authors who want to leverage Laravel’s internal APIs and extension points.Package Development
Laravel Package Development
A comprehensive guide to developing Laravel packages, covering service providers, publishing config/views/migrations, facades, auto-discovery, and deferred loading.
Testing Laravel packages with Orchestra Testbench
Set up Orchestra Testbench for Laravel package testing and verify service providers, facades, configuration, and database behavior.
Develop Laravel packages with Testbench Workbench
Use Testbench Workbench to build a realistic package development environment with routes, migrations, and a local app runtime.
Package Version Compatibility Management
Practical guide to maintaining package compatibility across Laravel and PHP major versions, including composer.json updates and GitHub Actions test matrices.
GeneratorCommand — Implementing custom make: commands
Extend GeneratorCommand to provide your own
make: commands in a Laravel package, covering stubs, namespace control, and testing.Package config merging and caching
Understand how shallow merging differs from recursive replacement, and maintain package config with published files and the config cache in mind.
Publishing and updating package migrations
Learn how publishing differs from loading directly, the risks of timestamp changes and republishing, and how to ship schema changes to existing users.
Overriding and updating package views
Learn about view lookup order, compatibility of published templates, and update procedures that account for the Blade cache.
Package route registration and caching
Learn how to keep middleware and names separate, and how configuration changes relate to rebuilding the route cache.
Integrating package caches with optimize
Learn about registration keys for custom tasks, exclusions, execution order, and how failures are handled.
Package public assets and updates
Learn about distributing JavaScript and CSS, how tags select paths, overwriting, and republishing on Composer updates.
Package translation overrides and updates
Learn about partially overriding PHP translations, the shared key space of JSON translations, and how to update without breaking published translations.
Package service resolution hooks
Learn about deferred configuration with callAfterResolving(), applying it to already-resolved services, and idempotency pitfalls.
Registering package Artisan commands and resolving dependencies
Explains the difference between registration, instantiation and execution, and how injecting dependencies into handle() isolates side effects.
Registering and caching package event listeners
Learn about the difference between explicit registration and auto-discovery, avoiding duplicate registration, what event:cache covers, and verifying behavior during updates.
Package service lifetime design
Learn how scoped works internally, the dependencies a singleton holds on to, and how to isolate state in long-running workers.
Package middleware registration and scope
Explains separating alias registration from application, avoiding group overrides, and verification with cached routes.
Package Blade extensions and the compilation cache
Learn when custom directives and conditionals run, and how to manage the cache during updates.
Registering and re-resolving package Storage drivers
Explains registering the creation logic, how disks are retained and re-resolved, and the verification you need beyond fake.
Custom notification channels and delivery testing for packages
Explains channel resolution by class name, recipient routing, queued processing, and testing real delivery.
Package container tags and plugin aggregation
Learn how tagged() resolves lazily, how giveTagged() converts to an array, and the pitfalls of duplicate registration and lifecycles.
HTTP clients and testing in packages
Learn how to use the shared Factory, isolate state per request, and verify requests and exceptions with fake.
Extending and re-resolving log channels in packages
Learn about custom and via, registering your own driver, and verification that accounts for retained channels and fallbacks.
Custom cache stores and contracts in packages
Learn about registration timing, the division of roles between Store and Repository, TTL conversion, and the scope of support for features such as locks.
Registering and testing mail transports in packages
Learn how to separate mailer names from transport names, re-resolve mailers after configuration changes, and verify delivery paths that fakes cannot check.
Package contextual attributes and dependency resolution
Explains injecting configuration with custom attributes, resolution precedence, the difference between make and call, and the lifetime of already-built services.
Registering and maintaining scheduled tasks in packages
Explains explicit opt-in, registering after the Schedule resolves, duplicate registration and lock names, and verification after configuration changes.
Custom session drivers in packages
Explains the handler storage contract, explicit selection, TTL and storage format, and how already-built Stores are retained and verified.
Extending database connections in packages
Explains extending connection names and driver names, creation precedence, and how connections are retained and recreated.
Registering dynamic relationships in packages
Add relationships without modifying models, and verify explicit keys, name collisions and inheritance, and the lifetime of registration state.
Registering string validation rules in packages
Explains registering with the Factory, messages and translations, the difference between implicit and dependent rules, and the lifetime of already-created Validators.
Framework Internals
Application Structure in Laravel 11 and Later
A deep dive into the Slim Application Skeleton, covering Application::configure() through ApplicationBuilder internals.
The Macroable Trait
How to add custom methods to existing Laravel classes using Macroable, without modifying core code.
The Conditionable Trait
How when() and unless() work internally, and patterns for keeping method chains clean with conditional logic.
Illuminate\Support\Manager — anatomy of the driver system
The abstract base class behind Laravel’s driver system. Learn to register custom drivers, extend built-in managers, and use MultipleInstanceManager.
The Pipeline Pattern
How Illuminate\Pipeline\Pipeline works, and how to compose multi-step processing chains with the pipeline pattern.
The InteractsWithData trait
Design of InteractsWithData and how to add Laravel-style data access APIs to your own package classes.
tap() Helper and the Tappable Trait
How to use Laravel’s tap() helper and the Tappable trait, including practical implementation patterns.
PHP Attributes
Use PHP attributes introduced and enhanced in Laravel 13 to declare job and model configuration in a more expressive way.
The once() helper internals
How the Once and Onceable classes back once() with a WeakMap cache, and how Eloquent’s PreventsCircularRecursion reuses the same pattern.
Eloquent Deep Dives
Eloquent Custom Casts
Implement CastsAttributes for custom casts. Covers Value Object casts, inbound-only casts, cast parameters, and the Castable pattern.
Eloquent Observers and Model Events
How Eloquent model events work and how to use Observer classes to handle them centrally. Includes the #[ObservedBy] attribute.
Eloquent Scopes
How local and global scopes work, with a look at SoftDeletingScope internals and practical patterns for multi-tenancy and publish/draft filtering.
Collection Deep Dive
Laravel Collection internals: historical evolution, class structure, PHPDoc generics, and a practical source-reading path.
Higher Order Messages
How HigherOrderCollectionProxy enables the $collection->map->method() syntax, and practical patterns for Eloquent collections.
Eloquent afterQuery and the result contract
How local scopes process results, and how types, call counts, and page detection differ between retrieval methods.
MCP & AI
Building an MCP Server with Laravel
Build a production-ready MCP server using the laravel/mcp package. Covers tools, resources, prompts, authentication, testing, and deployment.
Creating a Custom Provider for AI SDK
Understand the Laravel AI SDK source code and implement custom providers for AI services not supported out of the box.
Creating a Custom Agent for Boost
Deep dive into Laravel Boost’s extension architecture and implement custom agents using the SupportsGuidelines, SupportsMcp, and SupportsSkills contracts.
Agent Middleware in Laravel AI SDK
Covers per-step execution order, processing after model responses, and stopping based on cumulative tokens.
Auth, Validation & More
Custom Authentication Guards
Implement the Guard and StatefulGuard interfaces to build custom authentication guards, from API token auth to multi-guard applications.
Custom Validation Rules
Extend Laravel’s validation with rule objects and closures, from basic implementations to advanced data-aware and validator-aware rules.
Rate Limiting
Configure custom rate limiters with the RateLimiter facade, apply them to routes, and handle high-traffic scenarios with Redis-backed limiting.
Advanced Testing with Pest
Master Pest: the Expectation API, datasets, mocking, HTTP fakes, and architecture tests for well-structured codebases.