LARAVEL 8 Features

LearnNewTech
5 min readJan 15, 2022

--

Introduction:

Laravel 8, the most recent version of the Laravel framework, was released on September 8. Laravel 8 comes with exciting new features and a guide to upgrade. Laravel creator Taylor Otwell announced some of those new features in his Laracon presentation. This post contains a summary of some of the new capabilities announced. Let’s take a look at some of those great new features!

1. app/Models Directory

The artisan:make model command will create the model in the app/Models directory.

In Older Version we need to create directory manually.

2. New Landing Page

Laravel 8 comes with a new landing page for a brand new install. It is now redesigned and It is built using TailwindCSS, includes light and dark-mode capabilities, and by default extends links to SaaS products and community sites.

3. Controllers Routing Namespacing

We can add namespace route file.

Older Version Routing Format:

Route::get(‘/’, ‘Front\FrontendController@index’)->name(‘front.index’);

Larvel 8 Routing:

Import the Class name in routing.

4. Route Caching

Laravel uses route caching to compile your routes in a PHP array that is more efficient to deal with. In Laravel 8, it’s possible to use this feature even if you have closures as actions to your routes. This should extend the usage of route caching for improved performance.

5. Attributes on Extended Blade Components

In Laravel 7 the child components didn’t have access to the $attributes passed to it. In Laravel 8 these components were enhanced and it is now possible to merge nested component attributes. This makes it easier to create extended components.

6. Better Syntax for Event Listening

In the previous versions of Laravel, when creating a closure-based event listener there was much repetition and a cumbersome syntax.

In Laravel 8 it’s simpler and cleaner:

7. Queueable Anonymous Event Listeners

In Laravel 8 it is possible to create queueable closure from anywhere in the code. This will create a queue of anonymous event listeners that will get executed in the background. This feature makes it easier to do this, while in previous versions of Laravel you would need to use an event class and an event listener (using the ShouldQueue trait).

8. Maintenance Mode

This is especially useful when you need to do some maintenance on your application and you want to take it down for your users but still let your developers investigate bugs. This will create a secret cookie that will be granted to whoever hits the correct endpoint, allowing it to use the application while in maintenance mode.

Pre-rendering an error view is a safe way for not exposing errors to your end user when your application is down (during a new deployment, for example). The Laravel 8 framework guarantees that your predefined error page will be displayed before everything else from the application.

This combines the new features and will make the application only display a single predefined route, while still allowing for the people who have the secret to test and debug. This can be very useful when launching a new app.

9. Closure Dispatch “Catch”

Laravel has a pretty robust queue system that accepts a closure queue that will get serialized and executed in the background. Now we have a way to handle failures in case your job fails.

10. Exponential Backoff Strategy

This is an algorithm that decreases the rate of your job in order to gradually find an acceptable rate.

Now Laravel has this capability too, which is handy for jobs that deal with external APIs, where you wouldn’t want to try again on the same amount of time. It can also be used to dynamically generate the return array, setting different times to wait before retrying.

11. Job Batching

Modeled after the Sidekiq and Ruby library, job batching makes it easy to handle many jobs at the same time concurrently. It’s also easy to be notified when all jobs are complete, or when there’s any error on it’s execution. You can see more details on the PR that added this functionality.

12. Rate Limiting

Rate limiting provides a new and more convenient way of limiting the use of your routes.

13. Schema Dumping

Schema dumping is a way to squash migrations to a single file. It generates a schema file that has the whole schema for your database in a SQL form. This is used during development, useful for integrating new developers on your project that already has a large number of migrations. It supports MySQL, Postgres, SQLite.

14. Model Factories

Model factories are class based factories that add a lot of new features to Laravel 8. For each model there’s also a factory class, where there is a definition method that says which attributes it will generate for that model. Your models make use of that factory through the Factory trait.

15. Laravel Jetstream

Laravel Jetstream is a brand new scaffolding for Laravel released as an open-source package. It builds an application using TailwindCSS and TailwindUI, includes login, registration, two-factor authentication, session management. It offers two versions for handling frontend: Livewire (TALL Stack) or InertiaJS (VueJS)

--

--

No responses yet