Laravel 开源生态更新日志(2025年8月)
Laravel 开源生态的最新更新和改进。
Laravel Framework 12.x
Add withHeartbeat Method to LazyCollection
Pull request by @JosephSilber
$collection
->withHeartbeat(CarbonInterval::minutes(5), function () {
// ...
})
->each(function ($item) {
// ...
});The new withHeartbeart method allows you to run a callback at regular time intervals while the collection is being lazily enumerated, particularly useful for long-running processes.
Add toPrettyJson Method
Pull request by @WendellAdriel
$collection = collect([1,2,3]);
// Instead of this:
$collection->toJson(JSON_PRETTY_PRINT);
// You can now do this:
$collection->toPrettyJson();Add allowedUrls Through preventStrayRequests
Pull request by @rabrowne85
Http::allowStrayRequests([
'http://127.0.0.1:13714/*',
]);The Http::allowStrayRequests method now accepts an argument that allows you to specify URLs that tests are allowed to send requests to when using Http::preventStrayRequests.
Add "Copy as Markdown" Button to Error Page
Pull request by @mpociot
There is now a "Copy as Markdown" button on the Laravel exception page. When clicking this button, a markdown representation of the exception is copied to the users clipboard, which can then be used for AI agents/LLMs.
Add New mergeVisible, mergeHidden and mergeAppends Methods
Pull request by @jonerickson
protected function initializeTwoFactorAuthentication(): void
{
$this->mergeHidden([
'app_authentication_secret',
'app_authentication_recovery_codes',
]);
$this->mergeCasts([
'app_authentication_secret' => 'encrypted',
'app_authentication_recovery_codes' => 'encrypted:array',
]);
}Additional attribute helper methods added to Eloquent models for merging visibility-related arrays, bringing them in line with existing helpers like mergeCasts, mergeFillable, and mergeGuarded.
Add Arr::push()
Pull request by @inxilpro
if ($this->hasChanges($data)) {
Arr::push($result, 'pending.changes', $data);
}A new Arr method that allows you to push something to an array if the array exists, or initialize it to an empty array and then push to it if it doesn't.
Inertia
Introduction of the Form Component
Pull request by @pascalbaljet
<script setup>
import { Form } from "@inertiajs/vue3";
</script>
<template>
<Form action="/users" method="post">
<input type="text" name="name" />
<input type="email" name="email" />
<button type="submit">Create User</button>
</Form>
</template>A new <Form> component that behaves much like a classic HTML form and simply allows Inertia to intercept the network call on form submission. This new component greatly reduces the boilerplate needed to create a form with Inertia.
Support for Passing Wayfinder Objects to Router Methods
Pull request by @pascalbaljet
import UserController from "@/actions/App/Http/Controllers/UserController";
// Regular visits
router.visit(UserController.store());
// Prefetching
router.prefetch(UserController.index());
router.getPrefetching(UserController.index());
router.getCached(UserController.index());
router.flush(UserController.index());Adds support for passing Wayfinder-like objects into router methods instead of specifying the URL and method manually.
Tag-Based Cache Invalidation for Prefetch Requests
Pull request by @pascalbaljet
// Specify cache tags via the Link component
<Link href="/users/1" prefetch="hover" :tags="['user', 'profile']">
View Profile
</Link>
// Or via prefetch method on the route
router.prefetch(
'/users',
{ method: 'get', data: { page: 2 } },
{ cacheFor: '1m', tags: ['users'] }
)
// Flushes all cache entries tagged with 'user'
router.flushByTags(['user'])
// Flushes entries tagged with 'user' OR 'product'
router.flushByTags(['user', 'product'])
// Flush via visit
router.visit('/users', {
invalidate: ['user']
})
// Flush via useForm helper
form.post('/users', { invalidate: ['users'] })Introduces tag-based cache invalidation for prefetch requests. This enables better control over the prefetch cache without having to flush everything.
Support for Passing Custom Component to as Prop of Link Component
Pull request by @pascalbaljet
<Link as={CustomButton} method="post" href="/user" data={{ test: "data" }}>
Custom Component with Data
</Link>The Inertia Link component now supports custom components instead of just HTML tags such as a or button.
Boost
Laravel Boost was released this month! Not only was it just released, it is already aware and up-to-date with the just-released Pest 4 and Filament 4.
Add enabled Option to Config
Pull request by @xiCO2k
Adds a config('boost.enabled') option to allows users to specifically enable/disable Boost in certain scenarios outside of environment constraints.
Update Pint Guideline to Use --dirty Flag
Pull request by @yitzwillroth
Updates Boost guidelines to prefer the usage of Pint with the --dirty flag for cleaner diffs and PRs.
React + Vue Starter Kits
Migrate useForm to New Inertia Form Component
Pull request by @joetannenbaum
import { Form } from "@inertiajs/react";
export default function Login() {
return (
<Form action="/login" method="post">
{/* Form fields */}
</Form>
);
}Reduces the boilerplate for all forms in the starter kits by replacing useForm with the new Inertia Form component.
Replace Ziggy With Wayfinder
Pull request by @joetannenbaum
import AuthenticatedSessionController from "@/actions/App/Http/Controllers/Auth/AuthenticatedSessionController";
import { Form } from "@inertiajs/react";
export default function Login() {
return (
<Form {...AuthenticatedSessionController.store.form()}>
{/* Form fields */}
</Form>
);
}Removes Ziggy from the starter kits and replaces it with the current version of Laravel Wayfinder, bringing end-to-end type safety to your routes.
100% Baseline Test Coverage
Pull request by @JaavierR
Adds the missing feature tests so that fresh projects start with 100% test coverage.
Sail
Allow Sail to Run Pest 4 Browser Tests
Pull request by @rogerio-pereira
Docker configuration updates to allow you to run Pest 4 browser tests in Sail.
VS Code Extension
Add DDEV Support
Pull request by @damms005
Adds proper support for DDEV, Docker-based PHP environments.
Add Support for Custom View Extensions
Pull request by @ryangjchandler
The extension now recognizes custom registered view extensions such as .blade.sh or .blade.ts and will now autocomplete and link correctly to these files.
Support for Configs in Subfolders
Pull request by @N1ebieski
The extension now supports configs in nested subfolders (e.g. config/foo/bar/baz.php), providing better autocomplete and linking.
Link Directly to Problem Files
Pull request by @N1ebieski
Now, when the extension warns you about an invalid value, such as a config key, the warning will directly link you to the file where you can fix the issue.
Autocompletion for Route::is and routeIs Methods
Pull request by @N1ebieski
Full autocomplete and linking support for the Route::is and routeIs methods.
Wayfinder
Introduce Route Utility Types for Improved DX
Pull request by @istiak-tridip
import type { RouteDefinition } from "@/wayfinder";
const sendRequest = (route: RouteDefinition<"post">) => {
//
};
sendRequest(StorePostController());Utility types are now exported, making them easier to consume if your app requires them.
Support for Providing Default URL Parameters via the Frontend
Pull request by @owenconti
setup({ el, App, props }) {
const root = createRoot(el);
setUrlDefaults({
workspace: props.initialPage.props.workspace.slug
});
root.render(<App {...props} />);
},In instances where Wayfinder is unable to determine the proper default URL params as defined by the server, you can now specify them on the client side using setUrlDefaults.