Laravel 8 is a newly released Laravel framework that launched on 8th September. Peers want to know what’s new in Laravel 8 and what improvement made in Laravel 7. Before understanding the Laravel 8 features, one needs to see the Laravel 6 version. As Laravel 6 framework switches to semantic versioning, we need to understand its process.
Let’s drive in and take a look at the latest Laravel 8 new features
Laravel 8 New Features
1. Laravel Jetstream
One of the best new features in Laravel 8 is Laravel Jetstream. It provides a fantastic starting point for developing Laravel applications development. It uses built-in options like:
- Login and Registration
- Email Verification
- Session Management
- Two Factor authentication
- Tailwind CSS designed
- Laravel Sanctum API Support
2. How is Laravel 8 features Jetstream used?
Developers can create a new application with Jetstream by using Laravel installer. One needs to add the following code:
Laravel new your-project –jet
Now choose the stack (Livewire or Inertia). Later run your database migrations like: PHP artisan migrate
Finally, check your app at localhost:8000 by running code: PHP artisan serve
That’s all it’s ready. Get set and explore your new Laravel Jetstream application. One can find the composer installation instructions that available in the Laravel Jetstream documentation.
3. Migration Squashing
Wondering what the best new features in Laravel 8? Well, Laravel 8 introduced another existing new feature migration squashing. With this, we do not need to scroll for longer to open the migration folder. When comparing Laravel 8 vs Laravel 7 migration squashing is one best features of Laravel 8. Using this, one can condense migration files into a single SQL file by using the below code:
PHP artisan schema: dump
PHP artisan schema: dump – prune
Laravel comes with a new schema file database/schema. One needs to use the migration squashing feature to run the schema. Using this feature, Laravel will run the SQL from the schema and then move on to create later in the migration folder.
4. Model Updates
The new features in Laravel 8, i.e. app/Models directory, are back. In the Laravel 5 version, a lot of developers observed that the Models directory was missing. With this new release Laravel feature, the app directory was introduced. Using this feature, one need not create a folder. One need not require a lot of developers. And need not make an extra nuisance. Laravel 8 comes with an app/models directory that can be restored quickly.
5. Model Factory Classes
Taylor Otwell rewrote the Eloquent model factories as classes. If we compare Laravel 8 vs Laravel 7, then we can better understand the model factor classes.
Laravel 7.x User Factory code:
Laravel 8 User Factory code:
With the above code, we can say that Laravel 8 factory classes can extend the base Laravel factory class. Let’s take a look at how Laravel 7 vs Laravel 8 different.
Use factories in Laravel 7
Use factories in Laravel 8
6. Job Batching
For Laravel, jobs are tasks that are performed as part of a queue to accomplish something. The Laravel 8 features use new batching functionality with defining jobs. Let’s say, for example, use a simplified batchable unit like given below:
As soon as the batch job is set, you can dispatch a batch in your controller using the batch method of the bus façade.
7. Get better Rate Limiting
Here’s the rate-limiting of Laravel 7
Here’s the rate-limiting of Laravel 8
Apply to pre-configured rate limiter along with route throttle.
8. Maintenance Mode
Taylor Otwell contributed to the maintenance mode. In the features of Laravel 8, PHP artisan down maintenance mode. It’s bypass using an allow list that accessed the application. The feature was removed to get a simpler solution. In maintenance mode, one uses the secret option to specify a maintenance mode:
PHP artisan down – – secret = “1630542a-246b-4b66-afa1-dd72a4c43515”
After maintenance mode is placed, one navigates the application URL matching. Laravel uses maintenance mode with bypass cookies to your browser. One can redirect the application route. As soon as a cookie issued to your browser, one can browse the application normally.
9. Pre-Rendering Maintenance Mode
Utilize the PHP artisan down command during deployment. The user can encounter errors while composer dependencies and infrastructure components continue to update. With this Laravel framework, one can determine your application and render the maintenance mode using a template engine. To pre-render a template of your choice using the down command render option.
php artisan down – – render = “errors: : 503”
10. Closure Dispatch / Chain
Use the new catch method and provide a closure that execute if a queue closure fails to complete successfully after exhausting. Check the queue configured retry attempt:
use Throwable;
dispatch(function () use ($podcast) {
$podcast->publish();
})->catch(function (Throwable $e) {
// This job has failed…
});
11. Dynamic Blade Components
Taylor contributed Dynamic Blade Components. There are times when we need to render components but don’t know which component to render until runtime. In this situation, one needs to use Laravel’s dynamic component to render based on a runtime value like:
<x-dynamic-component :component=”$componentName” class=”mt-4″ />
Wrapping up
We have checked new features in Laravel 8, where Taylor and the teamwork hard to add a feature that benefits developers. Talking about Laravel 8, it requires PHP 7.3 and more upgrades. As one of the best Laravel app development companies, we offer the best Laravel shift service or custom-based requirements. If you’re looking for innovative Laravel solutions, hire Laravel developers and grow your business with ease.
Comments
Post a Comment