# Knowledge of Laravel: English Advanced Topics ## Advanced Topics ### AI Development - [Building an MCP Server with Laravel](https://kawax.biz/en/advanced/mcp-server.md): Build a production-ready MCP server using the laravel/mcp package. A practical guide covering tools, resources, prompts, authentication, testing, and deployment. - [Creating a Custom Agent for Boost](https://kawax.biz/en/advanced/boost-custom-agent.md): A deep dive into Laravel Boost's extension architecture, explaining how to create custom agents that implement the SupportsGuidelines, SupportsMcp, and SupportsSkills contracts. - [Creating a Custom Provider for AI SDK](https://kawax.biz/en/advanced/ai-sdk-custom-provider.md): Understand the Laravel AI SDK source code and implement custom providers for AI services not supported out of the box. - [Agent Middleware in Laravel AI SDK](https://kawax.biz/en/advanced/ai-sdk-agent-middleware.md): Learn how middleware runs on each model call in the Laravel 13 AI SDK, how to process responses, and how to stop based on cumulative tokens. ### Design Patterns - [The Pipeline Pattern](https://kawax.biz/en/advanced/pipeline.md): How Illuminate
ipeline
ipeline works, and how to compose multi-step processing chains using the pipeline pattern. - [Fluent Class](https://kawax.biz/en/advanced/fluent.md): Learn how to use the Illuminate\Support\Fluent class to work with array data as objects. A hidden gem in Laravel since its early versions. - [The Macroable Trait](https://kawax.biz/en/advanced/macroable.md): How to use Illuminate\Support\Traits\Macroable to add custom methods to existing Laravel classes without touching core code. - [The Conditionable Trait](https://kawax.biz/en/advanced/conditionable.md): How when() and unless() work internally, and patterns for keeping method chains clean with conditional logic. - [The InteractsWithTime Trait](https://kawax.biz/en/advanced/interacts-with-time.md): A utility trait for time and delay calculations used across caches, queues, and console components in Laravel. - [The ForwardsCalls trait](https://kawax.biz/en/advanced/forwards-calls.md): Use Illuminate\Support\Traits\ForwardsCalls to build safe proxy/decorator APIs with method forwarding and fluent chains. - [tap() Helper and the Tappable Trait](https://kawax.biz/en/advanced/tap.md): Learn how to use Laravel's tap() helper and Illuminate\Support\Traits\Tappable trait, including practical implementation patterns. - [The once() helper internals — Once, Onceable, and PreventsCircularRecursion](https://kawax.biz/en/advanced/once-helper.md): A deep dive into the once() global helper, powered by Illuminate\Support\Once and Onceable, and how the same pattern powers Eloquent's PreventsCircularRecursion trait. - [The Dumpable Trait](https://kawax.biz/en/advanced/dumpable.md): Use Illuminate\Support\Traits\Dumpable to add dump() / dd() to your own classes and debug fluent chains without breaking flow. - [Support Contracts (Arrayable / Jsonable / Htmlable / Responsable)](https://kawax.biz/en/advanced/support-contracts.md): A practical guide to Laravel 13 support contracts in Illuminate\Contracts\Support, based on official framework source code. - [The Lottery class](https://kawax.biz/en/advanced/lottery.md): Use Illuminate\Support\Lottery to implement probabilistic operations with an elegant fluent API. Covers real-world use cases, Laravel internals, and deterministic testing. - [Higher Order Messages](https://kawax.biz/en/advanced/higher-order-messages.md): How the HigherOrderCollectionProxy enables the $collection->map->method() syntax, and practical patterns for working with Eloquent collections. - [Collection Deep Dive](https://kawax.biz/en/advanced/collection-deep-dive.md): Learn Laravel Collection internals through its historical evolution, class structure, PHPDoc generics, and a practical source-reading path. - [Illuminate\Support\Manager — anatomy of the driver system](https://kawax.biz/en/advanced/manager.md): The abstract base class behind Laravel's driver system since version 4.0. Learn how to register custom drivers, extend built-in managers, and use MultipleInstanceManager. - [PHP Reflection API](https://kawax.biz/en/advanced/php-reflection.md): How the PHP Reflection API works and how Laravel's IoC container and package development use it. - [PHP FFI](https://kawax.biz/en/advanced/ffi.md): An overview of PHP FFI (Foreign Function Interface), supported environments, and practical wrapping patterns using VOICEVOX Core for PHP. - [PHP AST](https://kawax.biz/en/advanced/php-ast.md): An overview of PHP AST (Abstract Syntax Tree), its role in the PHP runtime, and practical code parsing and transformation patterns using nikic/PHP-Parser. ### Package Development - [Laravel Package Development](https://kawax.biz/en/advanced/package-development.md): A comprehensive guide to developing Laravel packages centered on service providers, covering everything from publishing config, views, and migrations to facades, auto-discovery, and deferred loading. - [Package auto-discovery internals](https://kawax.biz/en/advanced/package-discovery.md): Read through the internal implementation of the PackageManifest class and learn how composer.json extra.laravel data is cached and loaded as bootstrap/cache/packages.php. - [The InteractsWithData trait](https://kawax.biz/en/advanced/interacts-with-data.md): Understand the design of `Illuminate\Support\Traits\InteractsWithData` and how to add Laravel-style data access APIs to your package classes. - [Deferred Service Providers](https://kawax.biz/en/advanced/deferred-provider.md): Learn how to implement the DeferrableProvider interface for lazy-loading services. A subtle but impactful feature for optimizing package performance. - [Package Version Compatibility Management](https://kawax.biz/en/advanced/package-versioning.md): A practical guide to maintaining Laravel package compatibility through major Laravel and PHP version upgrades, covering composer.json updates, GitHub Actions test matrices, and end-of-life strategies. - [GitHub Actions Pinning and Security](https://kawax.biz/en/advanced/github-actions-pinning.md): Secure your package's supply chain by pinning GitHub Actions dependencies to commit SHAs instead of version tags. Learn Dependabot configuration and automated update strategies used by official Laravel projects. - [Package CHANGELOG and Release Management](https://kawax.biz/en/advanced/package-changelog.md): From managing changelogs to automating GitHub Releases, learn the release management practices needed for long-term Laravel package maintenance. - [Testing Laravel packages with Orchestra Testbench](https://kawax.biz/en/advanced/package-testing.md): Set up Orchestra Testbench for Laravel package testing and verify service providers, facades, configuration, and database behavior. - [Develop Laravel packages with Testbench Workbench](https://kawax.biz/en/advanced/package-workbench.md): Use Orchestra Testbench Workbench to build a realistic package development environment with routes, migrations, and a local app runtime. - [GeneratorCommand — Implementing custom make: commands](https://kawax.biz/en/advanced/generator-command.md): Learn how to extend Illuminate\Console\GeneratorCommand to provide your own make: commands in a Laravel package. Covers stub files, namespace control, stub publishing, and testing. - [Creating a Laravel Starter Kit](https://kawax.biz/en/advanced/starter-kit-creation.md): Learn how to create, publish, and maintain a Laravel starter kit on Packagist with continuous version support. - [Package Static Analysis (PHPStan / Larastan)](https://kawax.biz/en/advanced/package-static-analysis.md): A guide to setting up PHPStan and Larastan for Laravel packages, covering configuration, type annotations, and CI automation to improve type safety and long-term maintainability. - [Package config merging and caching](https://kawax.biz/en/advanced/package-config-merging.md): Learn from Laravel 13's ServiceProvider implementation how shallow merging differs from recursive replacement, the pitfalls of numerically keyed arrays, and how to maintain packages with the config cache in mind. - [Publishing and updating package migrations](https://kawax.biz/en/advanced/package-migrations.md): Based on the Laravel 13 implementation, this guide explains the difference between publishesMigrations and loadMigrationsFrom, timestamp changes on publish, the risks of republishing, and how to deliver schema changes to existing users. - [Overriding and updating package views](https://kawax.biz/en/advanced/package-views.md): Based on the Laravel 13 implementation, this guide explains the lookup order for namespaced views, maintaining published Blade templates, and the difference between the view cache and cached lookup results. - [Package route registration and caching](https://kawax.biz/en/advanced/package-routes.md): Based on the Laravel 13 implementation, this guide explains the role of loadRoutesFrom, keeping middleware and names separate, and how to apply configuration changes to the route cache. - [Integrating package caches with optimize](https://kawax.biz/en/advanced/package-optimization.md): Use Laravel 13's optimizes() to integrate your package's own cache generation and clearing into deployments. Learn about registration keys, exclusions, execution order, and exit codes on failure, based on the implementation. - [Package public assets and updates](https://kawax.biz/en/advanced/package-assets.md): Examine Laravel 13's publishing process and learn, from a long-term maintenance perspective, how to distribute JavaScript and CSS, how tags select paths, how the overwrite options work, and how to republish on Composer updates. - [Package translation overrides and updates](https://kawax.biz/en/advanced/package-translations.md): Examine Laravel 13's translation loader and learn how to partially override PHP translations, how JSON translations share keys, and how to update without breaking published translations. - [Package service resolution hooks](https://kawax.biz/en/advanced/package-service-resolution.md): Examine Laravel 13's callAfterResolving() and learn how to extend services whether or not they have been resolved yet, along with caveats for singletons, regular bindings, and repeated registration. - [Adding package diagnostics to about](https://kawax.biz/en/advanced/package-about.md): Learn how to use Laravel 13's AboutCommand to show your package's configuration state in CLI and JSON output, along with evaluation timing and long-term maintenance considerations. - [Registering package Artisan commands and resolving dependencies](https://kawax.biz/en/advanced/package-commands.md): Trace the path from commands() to Artisan startup in Laravel 13, and learn about separating command construction from execution, dependency injection, deferred providers, and long-term maintenance considerations. - [Registering and caching package event listeners](https://kawax.biz/en/advanced/package-events.md): Examine the event registration and event:cache implementation in Laravel 13, and learn about explicit registration in packages, duplicate registration with auto-discovery, dependency resolution, and how to verify behavior during updates. - [Package service lifetime design](https://kawax.biz/en/advanced/package-service-lifetimes.md): Examine how bind, singleton, and scoped are implemented in Laravel 13, and learn how to design packages that do not carry state over in long-running workers and how to test lifecycle boundaries. - [Package middleware registration and scope](https://kawax.biz/en/advanced/package-middleware.md): Examine the Laravel 13 Router implementation to learn how packages register middleware aliases, apply middleware explicitly, avoid overwriting groups, and verify behavior with route caching. - [Package Blade extensions and the compilation cache](https://kawax.biz/en/advanced/package-blade-extensions.md): Examine the Laravel 13 BladeCompiler to learn how to register custom directives and conditionals, separate compile time from runtime, and verify the view cache when a package is updated. - [Registering and re-resolving package Storage drivers](https://kawax.biz/en/advanced/package-filesystem-drivers.md): Examine the Laravel 13 FilesystemManager to learn how Storage::extend() registration works, how disk instances are retained, how to re-resolve disks after configuration changes, and how to verify drivers without relying on fake. - [Custom notification channels and delivery testing for packages](https://kawax.biz/en/advanced/package-notification-channels.md): Learn how to ship Laravel 13 notification channels from a package, covering resolution by class name, destination routing, queueing, and testing real delivery. - [Package container tags and plugin aggregation](https://kawax.biz/en/advanced/package-container-tags.md): Use container tags in Laravel 13 to aggregate implementations from multiple packages, and examine the lazy resolution of tagged(), how it differs from giveTagged(), duplicate registration, and lifecycles. - [HTTP clients and testing in packages](https://kawax.biz/en/advanced/package-http-client.md): Use Laravel 13's shared HTTP Factory to design API clients with per-request state isolation, service registration, and verification through Http::fake(). - [Extending and re-resolving log channels in packages](https://kawax.biz/en/advanced/package-logging.md): Choose between Laravel 13's custom/via and LogManager::extend(), and test logging features while accounting for channel retention, forgetChannel(), and fallbacks. - [Custom cache stores and contracts in packages](https://kawax.biz/en/advanced/package-cache-drivers.md): Examine Laravel 13's CacheManager and Store contract to understand when to register drivers, how the Repository converts TTLs, how instances are retained, and what support for features such as locks requires. - [Registering and testing mail transports in packages](https://kawax.biz/en/advanced/package-mail-transports.md): Examine Laravel 13's MailManager to understand how to register a transport from a package, how configuration is passed, how mailers are retained and re-resolved, and which delivery paths fakes cannot verify. - [Package contextual attributes and dependency resolution](https://kawax.biz/en/advanced/package-contextual-attributes.md): Examine Laravel 13's ContextualAttribute to understand attributes that inject package configuration, resolution precedence, the differences between make and call, and testing and maintenance for long-lived services. - [Registering and maintaining scheduled tasks in packages](https://kawax.biz/en/advanced/package-scheduling.md): Examine Laravel 13's Schedule and post-resolution hooks to understand designing package scheduled tasks that are explicitly enabled, duplicate registration, lock names, configuration changes, and testing. - [Custom session drivers in packages](https://kawax.biz/en/advanced/package-session-drivers.md): Examine Laravel 13's SessionManager to understand the SessionHandlerInterface storage contract, explicit driver selection, TTLs and serialization, retained Stores, and testing. - [Extending database connections in packages](https://kawax.biz/en/advanced/package-database-connections.md): Examine Laravel 13's DB::extend and Connection::resolverFor to understand the precedence of connection names and driver names, retained connections, recreation, and package testing. - [Registering dynamic relationships in packages](https://kawax.biz/en/advanced/package-dynamic-relations.md): Examine Laravel 13's resolveRelationUsing to understand adding relationships without modifying models, specifying keys, name collisions and inheritance, the lifetime of registered state, and testing. - [Registering string validation rules in packages](https://kawax.biz/en/advanced/package-validation-extensions.md): Examine Laravel 13's Factory::extend to understand the calling contract of string rules, error messages and translations, the difference between Implicit and Dependent, the lifetime of created Validators, and testing. - [Package response macros and HTTP contracts](https://kawax.biz/en/advanced/package-response-macros.md): Examine Laravel 13's ResponseFactory and Macroable to understand package-specific JSON responses, name collisions, the lifetime of registration state, and testing and maintaining HTTP contracts. - [Package service decoration and extend](https://kawax.biz/en/advanced/package-service-decoration.md): Read Laravel 13's Container::extend() to learn contract-preserving decorators, registering before and after resolution, how long singleton decorations last, double decoration, and testing across upgrades. ### Application Structure - [Application Structure in Laravel 11 and Later](https://kawax.biz/en/advanced/app-structure.md): A deep dive into the Slim Application Skeleton introduced in Laravel 11, covering everything from Application::configure() to ApplicationBuilder internals. - [Migration Guide: Old Structure to Slim Application Skeleton](https://kawax.biz/en/advanced/app-structure-migration.md): Step-by-step guide to migrating a Laravel 10 application from the legacy structure to the Slim Application Skeleton introduced in Laravel 11. - [Laravel 11+ New Application Structure FAQ](https://kawax.biz/en/advanced/app-structure-faq.md): Common questions and answers when working with the Slim Application Skeleton introduced in Laravel 11. Aimed at developers joining a project mid-way or learning from older books and tutorials. ### Laravel 13 New Features - [PHP Attributes](https://kawax.biz/en/advanced/php-attributes.md): Learn how to use the PHP attributes introduced and enhanced in Laravel 13 to declare job and model configuration in a more expressive way. - [Controller PHP Attributes](https://kawax.biz/en/advanced/controller-attributes.md): Use #[Middleware], #[WithoutMiddleware], and #[Authorize] attributes added in Laravel 13 to declaratively configure middleware and authorization on controllers. ### Eloquent Deep Dive - [Eloquent Observers and Model Events](https://kawax.biz/en/advanced/eloquent-observers.md): How Eloquent model events work, and how to use Observer classes to handle them in one place. Includes the #[ObservedBy] attribute introduced in Laravel 10 and used throughout Laravel 13. - [Eloquent Scopes](https://kawax.biz/en/advanced/eloquent-scopes.md): How local and global scopes work in Eloquent, with a look at SoftDeletingScope from the framework internals, plus practical patterns for multi-tenancy and publish/draft filtering. - [Eloquent Custom Casts](https://kawax.biz/en/advanced/eloquent-casts.md): How to implement the CastsAttributes interface to build custom casts. Covers Value Object casts, inbound-only casts, cast parameters, and the Castable pattern. - [Eloquent Bootable Traits](https://kawax.biz/en/advanced/eloquent-bootable-traits.md): A deep dive into Eloquent's trait auto-boot mechanism. Learn the bootXxx() and initializeXxx() naming conventions and how to use PHP Attributes for explicit registration — an essential pattern for package development. - [Custom pivot models and chaperone](https://kawax.biz/en/advanced/eloquent-custom-pivot.md): How to treat belongsToMany pivot tables as custom Pivot models, plus the chaperone method added in Laravel 13 for automatic eager loading. - [Eloquent afterQuery and the result contract](https://kawax.biz/en/advanced/eloquent-after-query.md): Learn how to bundle result processing into local scopes with Eloquent afterQuery. Check execution order, return values, and the differences between first, pluck, cursor, and pagination against the Laravel 13 implementation. ### Validation Extensions - [Custom Validation Rules](https://kawax.biz/en/advanced/custom-validation-rules.md): Extend Laravel's validation system with rule objects and closures, from basic implementations to advanced data-aware and validator-aware rules. ### Authentication Extensions - [Custom Authentication Guards](https://kawax.biz/en/advanced/custom-auth-guard.md): Understand Laravel's authentication internals and implement custom guards using the Guard and StatefulGuard interfaces, from API token authentication to multi-guard applications. - [Laravel Fortify and Starter Kits](https://kawax.biz/en/advanced/fortify.md): Explore the internals of Laravel Fortify, the frontend-agnostic authentication backend. Covers why modern starter kits use Fortify, FortifyServiceProvider configuration, 2FA, and passkeys. ### Security - [Rate Limiting](https://kawax.biz/en/advanced/rate-limiting.md): Configure custom rate limiters with the RateLimiter facade, apply them to API routes with the throttle middleware, and handle high-traffic scenarios with Redis-backed limiting. ### Queues - [Queue Job Execution Control](https://kawax.biz/en/advanced/queue-job-control.md): How to use ShouldBeUnique, ShouldBeUniqueUntilProcessing, and DebounceFor to control duplicate execution and burst dispatches of queued jobs. ### Testing - [Advanced Testing with Pest](https://kawax.biz/en/advanced/testing-pest.md): Master Pest in Laravel projects: the Expectation API, datasets, mocking, HTTP fakes, and architecture tests for well-structured codebases. ### Realtime - [Inside the Mercure broadcast driver](https://kawax.biz/en/advanced/mercure-broadcasting.md): A source-level walkthrough of the Mercure broadcast driver added to the Laravel framework: its HTTP/SSE architecture, dual publish/subscribe JWTs, single-cookie channel authorization, and end-to-end encrypted channels.