What Is New in Laravel 8.0
| Category | Key Changes |
|---|---|
| New Features | Laravel Jetstream, Model Factories as Classes, Migration Squashing, Job Batching, Rate Limiting Improvements |
| Improvements | Blade Component Attributes, Dynamic Blade Components, Time Testing Helpers |
| Changes | Model Directory, Closure Dispatch, Maintenance Mode, Pagination Default |
| Deprecations | Legacy String Helpers, Arr::wrap() Parameter Order |
What's the big deal with Laravel Jetstream?
Laravel 8 introduces Jetstream, a robust application scaffolding. It replaces the legacy UI with a modern, feature-packed starter kit built on Tailwind CSS. Jetstream provides login, registration, email verification, two-factor authentication, session management, and API support via Laravel Sanctum out of the box. You can choose between Livewire or Inertia.js stacks for your frontend.
How are model factories different now?
Model factories are now class-based. Instead of defining factories with a global function, you now create a dedicated factory class that extends Illuminate\Database\Eloquent\Factories\Factory. This is a cleaner, more organized approach.
// Laravel 8 Style
class UserFactory extends Factory
{
public function definition()
{
return [
'name' => $this->faker->name,
'email' => $this->faker->unique()->safeEmail,
];
}
}
What improvements were made to job batching?
Job batching allows you to execute a batch of jobs and then perform a callback when the entire batch finishes. Laravel 8 adds the ability to cancel pending jobs within a batch if one job fails. This gives you much finer control over the execution flow of your queued jobs.
How did rate limiting get better?
Rate limiting is now more expressive. You can define named rate limiters in your RouteServiceProvider with custom logic for different parts of your application. This is far more flexible than the previous global throttle settings.
// Define a named limiter
RateLimiter::for('uploads', function (Request $request) {
return Limit::perMinute(10)->by($request->user()->id);
});
// Use it on a route
Route::post('/audio', 'AudioController@store')->middleware(['throttle:uploads']);
What changed with Blade components?
Blade components saw significant upgrades. You can now pass additional attributes to components that are automatically propagated to the root element of the component view. Dynamic components are also easier to use with the new x-is directive.
<x-alert type="error" :message="$message" class="mb-4" />
// The 'class' attribute is automatically merged
// with the component's existing class list
FAQ
Do I have to use Laravel Jetstream?
No, Jetstream is optional. It's an advanced starter kit. For simpler applications, you can still use the traditional Laravel UI scaffolding or start completely from scratch.
Are the old model factory definitions broken?
Yes, the old global function syntax is removed. You must convert your factories to the new class-based structure to use them in Laravel 8.
What is migration squashing?
It's a new Artisan command (schema:dump) that squashes your many migration files into a single SQL file. This can drastically speed up running tests if you have a large number of migrations.
How do time testing helpers work?
New methods like $this->travel(5)->days() or $this->freezeTime() were added. They let you manipulate the current time within your tests, making time-dependent logic much easier to test.
Where are models created by default now?
The php artisan make:model command now creates models in the app/Models directory instead of app/. The framework assumes this new path by default.