Version | Laravel 8 (Non-LTS) |
Bug fixes | Until March 8, 2021 |
Security fixes | Until Sep 8, 2021 |
Release Date | 8th Sep 2020 |
An announcement has been made of the release of a new version of Laravel 8 on September 8th 2020. The Laravel team has introduced usability improvements and bug fixes in the new version. They claim that the upgrade will take only 15-20 minutes.
What’s Inside Laravel 8?
Laravel 8 has introduced features like Laravel Jetstream, model factory classes, migration squashing, job batching, improved rate limiting, queue improvements, dynamic Blade components, Tailwind pagination views, time testing helpers, improvements to artisan serve, event listener improvements, and a variety of other bug fixes and usability improvements.
1. Laravel Jetstream
Laravel Jetstream is a beautifully designed application scaffolding for Laravel. Jetstream provides the perfect starting point for your next Laravel application and includes login, registration, email verification, two-factor authentication, session management, API support via Laravel Sanctum, and optional team management.
Jetstream is designed using Tailwind CSS and offers your choice of Livewire or Inertia scaffolding.
2. Skeleton change
Default Laravel application skeleton now contains an app/Models directory.
Eloquent model factories have been entirely re-written as class based factories and improved to have first-class relationship support. For example, the UserFactory included with Laravel is written like so:
3. Migration Squashing
you may accumulate more and more migrations over time. This can lead to your migration directory becoming bloated with potentially hundreds of migrations. If you would like, you may now “squash” your migrations into a single SQL file.
4. Job Batching
Laravel’s job batching feature allows you to easily execute a batch of jobs and then perform some action when the batch of jobs has completed executing. Job batching is now easier with new Bus::batch().
Bus::batch([ new Job1(), new Job2() ])->then(function (Batch $batch) { if ($batch->hasFailures()) { // die } })->success(function (Batch $batch){ //invoked when all job completed })->catch(function (Batch $batch,$e){ //invoked when first job failure })->allowFailures()->dispatch();
Example of Response:
4. Improved Maintenance Mode
you may use use the secret option to specify a maintenance mode bypass token:
After placing the application in maintenance mode, you may navigate to the application URL matching this token and Laravel will issue a maintenance mode bypass cookie to your browser:
5. Exception handling in Closure Dispatch / Chain
Using the new catch method, you may now provide a Closure that should be executed if a queued Closure fails to complete successfully after exhausting all of your queue’s configured retry attempts
6. Dynamic Blade Components
Sometimes you may need to render a component but not know which component should be rendered until runtime. In this situation, you may now use Laravel’s built-in dynamic-component component to render the component based on a runtime value or variable
7. Laravel Factory
Route::get('test-factory',function(){ return User::factory()->create(); }); Route::get('test-factory',function(){ return User::factory()->times(10)->create(); });
New Laravel 8 provides an easier way to seed model data with the new factory improvement. Let’s have a look at how cool the factory is now.
8. Queueable Closure functions in Events
Closure based event listeners may now be marked as queueable using the Closure based event listeners may now be marked as queueable using the Illuminate\Events\queueable function
9. Time Testing Helpers
When testing, you may occasionally need to modify the time returned by helpers such as now or Illuminate\Support\Carbon::now(). Laravel’s base feature test class now includes helpers that allow you to manipulate the current time
//goto to future
$this->travel(10)->seconds();
$this->travel(10)->minutes();
//back to past
$this->travel(-8)->seconds();
$this->travel(-8)->minutes();
10. Automatic reloading .env
The Artisan serve command has been improved with automatic reloading when environment variable changes are detected within your local .env file. Previously, the command had to be manually stopped and restarted.
Comments are closed.