Laravel Knowledge Patch
Use this patch when implementing, reviewing, testing, or upgrading Laravel applications and framework extensions.
Inspect composer.json first, then apply only guidance that exists in the application's installed framework version.
Trust the manifest, lockfile, application code, and tests when they show behavior that differs from this guidance.
Reference index
| Reference | Topics |
|---|---|
| Cache, sessions, and filesystems | Cache stores and locks, Redis, sessions, disks, and filesystem URLs |
| Database, Eloquent, and schema | Queries, models, relationships, casts, migrations, indexes, and driver behavior |
| Events, observability, and operations | Logging, lifecycle events, maintenance mode, reloads, and failure reporting |
| Framework core and container | Container attributes, contracts, collections, strings, context, and helpers |
| HTTP, routing, and processes | Requests, responses, routing, HTTP client, pagination, rate limits, and processes |
| Mail, notifications, and broadcasting | Mail transports, mailables, notification lifecycle, and broadcasting |
| Queues, jobs, and scheduling | Drivers, jobs, batches, workers, deferred execution, and scheduler controls |
| Testing, CLI, and tooling | Test isolation, fakes, dependency compatibility, Artisan, and development commands |
| Validation, authentication, and security | Rules, login behavior, authorization, request forgery protection, and encryption |
| Views, resources, and frontend | Blade, API resources, Vite, starter kits, fonts, and images |
Major-upgrade triage
Runtime and package constraints
- Laravel 13 requires PHP 8.3 and uses
laravel/framework:^13.0pluslaravel/tinker:^3.0. - Relevant Laravel 13 upgrades use Boost 2, PHPUnit 12, or Pest 4 constraints.
- Laravel 12 uses
laravel/framework:^12.0, Carbon 3, PHPUnit 11 or newer, or Pest 3. - Laravel 12 supports PHP 8.2 through 8.5; Laravel 13 supports PHP 8.3 through 8.5.
- Beanstalkd applications moving to Laravel 13 need Pheanstalk 8; version 5 is no longer supported.
Laravel 13 breaking changes
- Explicitly set
CACHE_PREFIX,REDIS_PREFIX, andSESSION_COOKIEwhen old cache, Redis, or cookie identifiers must remain stable. - Cache stores must implement
touch($key, $seconds). - Cached PHP objects require an allow-list in
cache.serializable_classes; the default rejects serialized classes. - Custom contract implementations must add the new dispatcher, response-factory, and email-verification methods.
- MySQL and MariaDB
upsert()require a non-emptyuniqueByargument. - Joined MySQL deletes now retain
ORDER BYandLIMIT; unsupported variants fail instead of becoming unbounded deletes. - Do not instantiate a model recursively from its own boot or trait-boot methods.
- Set custom polymorphic pivot table names explicitly when retaining an inferred singular table name.
- Update custom HTTP response overrides so
throw()andthrowIf()accept callback parameters. JobAttempted::$exceptionreplaces the booleanexceptionOccurredproperty.QueueBusy::$connectionNamereplacesQueueBusy::$connection.- Custom queue drivers must implement pending, delayed, reserved, and oldest-pending metrics.
- Explicit-domain routes take precedence over routes without domains regardless of registration order.
- Scheduling callbacks passed to
withScheduling()are registered whenScheduleresolves, not immediately. - Use
PreventRequestForgeryandpreventRequestForgery(...); the old CSRF middleware names are deprecated aliases. - Capture external values explicitly in manager extension closures because those closures are bound to the manager.
- Re-register custom
StrUUID, ULID, and random factories in each test setup that needs them. - Expect
Js::from()to emit unescaped Unicode. - Remove legacy global helpers that conflict with PHP 8.5 polyfills.
- Use the renamed Bootstrap 3 pagination views for direct references.
Laravel 12 breaking changes
- Convert custom
DatabaseTokenRepositoryexpiration arguments from minutes to seconds. - Expect associative input to
Concurrency::run()to return keyed results. - Optional class-typed constructor parameters with defaults keep those defaults during container resolution.
- Construct
Blueprintand database grammars with aConnection; removed prefix mutators are unavailable. HasUuidsgenerates ordered UUIDv7 values; useHasVersion4Uuidswhen UUIDv4 must remain.Request::mergeIfMissing()treats dotted keys as nested paths.- Duplicate route names resolve to the first registered route in cached and uncached routing.
- Configure the local disk root explicitly to retain
storage/app; the fallback is private storage. - Opt into SVG validation with
image:allow_svgorFile::image(allowSvg: true). - Account for
Eloquent\Collection::partition()returning a support collection. - Provide native MariaDB client binaries for database CLI operations.
High-value framework behavior
Container and core
- Closure bindings can infer their abstract from a declared return type.
Bind,BindWhen,Singleton, andScopedattributes reduce service-provider binding code.- Contextual attributes can inject context, database, cache, and other manager-selected values, including enum selectors.
- Contextual attribute resolution can inspect the target reflection parameter.
Context::scope()restores surrounding context after a callback.Context::remember()andrememberHidden()lazily populate missing values.- Collections support closure-based
pluck(), enum grouping and keys,reduceInto(), and callback-awarecontainsOneItem(). LazyCollectionsupports stepped ranges, heartbeats, and timeout callbacks.Arrhas typed getters, depth-limiteddot(), and iterable-awareevery(),some(), andlast().- Locale-aware number parsing can return
false; handle failed parses explicitly. Str::trim()removes invisible Unicode characters, whilestudly()andpascal()can normalize before conversion.- Concurrent runs accept timeouts, and process timeouts accept
CarbonInterval.
Database and Eloquent
- Database inspection spans all schemas by default; request schemas and qualification behavior explicitly when needed.
- PostgreSQL supports online indexes, virtual columns,
tsvector, precomputed full-text vectors, transaction poolers, and conversion expressions for changed columns. - MariaDB supports UUID fallback behavior and vector indexes; SQLite supports JSON, JSONB, transaction modes, pragmas, URI filenames, and polymorphic exclusions.
- MySQL schema operations support SSL credentials, DDL locks, and explicit SSL disabling for dump or restore workflows.
- Eloquent supports automatic relationship loading, one-of-many through relationships, nested
relationLoaded(), and nested-arrayloadMissing(). - Use the
Scopeattribute for local scopes; the earlierNamedScopename is obsolete. withAttributes(..., asConditions: false)supplies creation attributes without adding query predicates.whereAttachedTo(),withoutGlobalScopesExcept(),whereValueBetween(), andinOrderOf()cover common relationship and ordering cases.- Creation helpers accept lazy closure values, and pivot mutation methods have transactional
*OrFailvariants. - Value-object casts support mass assignment; first-party casts include binary, URI, fluent, HTML string, Unicode JSON, and mapped collections.
getPrevious()exposes values from immediately before the last save.- Stop using
orWhereKey()andorWhereKeyNot()because current Laravel 13 patch releases removed them.
HTTP and routing
Http::record()records real outbound requests without faking responses.preventStrayRequests()can allow selected real URL patterns.- HTTP batches support deferred execution, lifecycle hooks, request contexts, and bounded concurrency.
- Pending HTTP methods can return fluent promises; pools and batches can construct requests with
newRequest(). - HTTP connection and certificate failures surface through Laravel's HTTP exception abstraction.
Response::json()accepts JSON decoding flags such asJSON_BIGINT_AS_STRING.Request::get()is deprecated; chooseinput(),query(), or another source-specific accessor.eventStream()supports custom event names and initial messages.- Route metadata, parameter-name injection, closure source locations, and middleware-filtered listings improve routing tooling.
- Malformed encoded cursors return
null; validate the result before use. - The health route and maintenance mode can serve JSON-aware responses.
Queues and scheduling
Queue::route()centralizes job routing; a single string means the queue name.- Queue jobs support class attributes for tries, backoff, timeout, failure-on-timeout, delay, and inherited debounce behavior.
- Runtime queue selection overrides class-level queue attributes.
- SQS supports fair queues, named credential providers, and disk-backed overflow payloads.
- Redis Cluster works with queues and concurrency limiting.
- Failover queues and caches emit failure events that identify the originating exception or underlying store.
- Workers expose startup, idle, pause, resume, interruption, stopping, and stop-reason telemetry.
- Queue inspection returns payload and queue details without backend-specific access.
- Queue fakes inspect delayed and reserved jobs and expose before/after push hooks.
- Scheduler pause, resume, reload interruption, group callbacks, and environment-filtered listings are available.
schedule:list --json,queue:failedJSON, andqueue:monitoroldest-pending data support automation.
Cache, sessions, and filesystems
Cache::memo()adds request-local memoization and supportsflexible()stale-while-revalidate reads.Cache::funnel()provides driver-independent concurrency limiting.- Cache locks can refresh expiration; database-lock pruning can be disabled.
- Redis tagged-cache flushes are atomic and can use custom connections.
- The cache session driver uses
SESSION_DRIVER=cachewithSESSION_STOREselecting the store. - Scoped disks inherit the parent disk's
throwbehavior. - Local disks support temporary upload URLs.
- Served disks must have unique URIs, and generated filesystem URL paths are encoded.
Validation and authentication
Rule::anyOf()validates when any complete alternative rule set passes.Rule::contains()andin_array_keysvalidate required array values or keys.- Strict boolean, numeric, integer, and form-request modes reject loose or unknown input.
- The
imagerule excludes SVG unless explicitly allowed. - Uploaded files can be validated for character encoding.
- Fluent password rules handle
required()andsometimes()consistently and can stringify themselves. Auth::login()regenerates the session identifier.- Bcrypt can enforce its 72-byte input limit.
- Remember cookies store a MAC of the password hash, not the raw hash.
- Decryption authenticates ciphertext against all configured rotated keys.
Views, resources, mail, and frontend
- Models and collections can discover resources through convention or explicit resource attributes.
JsonApiResourcesupports JSON:API serialization and circular-reference deduplication.- Blade provides context blocks, isolated includes, stack detection, function or constant imports, and optimized fonts.
- Vite can limit preloads and customize asset paths.
- Resend supports raw and inline attachments.
- Notifications expose failure transport exceptions, post-send hooks, custom queued job classes, and missing-model deletion behavior.
- Mail supports Cloudflare Email Service and SES tenants.
Working method
- Read the installed framework constraint and lockfile version.
- Start with the major-upgrade checks when changing framework versions.
- Open only the topic references relevant to the code under review.
- Preserve exact defaults and final option names; several entries document reverted or renamed APIs.
- Add regression tests for changed routing, serialization, queue, session, schema, and validation behavior.