8 powerful new web development features in Laravel 8

Laravel is the most popular PHP framework, with over 1.2 million websites built on it. Since its release in June 2011, Laravel has caught the attention of many web developers, claiming to be the most widely used PHP framework.

Laravel offers a fast development environment, security and good development guides. Created and maintained by its creator Taylor Otwell, Laravel has continued to make improvements to its software. It follows a semantic versioning scheme and is currently at version 8.x.

Here are eight new features to look out for in Laravel 8.


1. Laravel Jetstream

This is the new app scaffolding feature in Laravel. It comes with out-of-the-box features like session tracking, login, registration, email verification, two-factor authentication, and optional team management.

Jetstream offers a choice of two scaffolding options: Livewire and Inertia.

Livewire is a responsive and dynamic library that offers the option to avoid using a JavaScript framework such as Vue.js. It uses the default Blade templating language. Livewire also offers the option to choose between quitting Blade or using Vue.js.

Inertia uses Vue.js as a template language.

Read more: What is Vue.js?

It gives all the power of Vue.js without the need for client side routing. If Vue is your preferred template language, then the Inertia stack is a good choice.

VIDEO OF THE DAY MAKEUSE

2. Crushing of migrations

As you develop your application, your migrations can add up. You can “overwrite” them in a single SQL file to avoid clicking. This option is available for MySQL or PostgreSQL users.

Laravel will create a schema file when the command diagram: dump is executed. When you try to migrate your database, Laravel will first migrate the SQL file associated with your schema. Subsequently, if there are any migrations that were not part of the scheme, then they will be executed.

3. Tailwind CSS

Laravel now uses the Tailwind CSS framework as the default pager. Tailwind is a utility-first CSS library that provides one-time use CSS classes. It offers the advantage of having your style information in one place rather than scattering it all over the place. You can apply predefined classes directly to your HTML document.


Tailwind also offers the ability to create responsive designs. It offers a first mobile system similar to that of Bootstrap. This implies that unprefixed utilities respond on all screen sizes while prefixed utilities take effect at particular points.

Tailwind also offers a just-in-time mode enabled so that your styles are generated on demand rather than having everything rendered at the time of the initial build. This makes it faster than using regular CSS. Another advantage this offers is that you don’t need to get rid of your unused production styles, giving you the flexibility to use your code in multiple environments.

It’s also worth noting that Laravel Jetstream was built using Tailwind.

4. Work package

You can use this feature to run a batch of tasks at a given time and perform one or more actions when their execution is complete. the Bus front provides a batch method that allows you to distribute jobs.

You can do this in tandem with other completion reminders like socket, then and ultimately to add functionality to your jobs.

use AppJobsProcessPodcast;
use AppPodcast;
use IlluminateBusBatch;
use IlluminateSupportFacadesBus;
use Throwable;
$batch = Bus::batch([
new ProcessPodcast(Podcast::find(1)),
new ProcessPodcast(Podcast::find(2)),
new ProcessPodcast(Podcast::find(3)),
new ProcessPodcast(Podcast::find(4)),
new ProcessPodcast(Podcast::find(5)),
])->then(function (Batch $batch) {
// All jobs completed successfully...
})->catch(function (Batch $batch, Throwable $e) {
// First batch job failure detected...
})->finally(function (Batch $batch) {
// The batch has finished executing...
})->dispatch();
return $batch->id;

To get started, you need to create a migration table that will contain task metadata such as completion rates. Use the command php craftsman queue: batch table to do this. Then php artisan migrate to migrate them. Now you can set up your tasks in batches and then ship them when you’re ready.

5. Model factory classes

First, let’s talk about model factories. These are used to seed your databases with test data. This fake data is important for testing purposes before actual user data is inserted.

In Laravel 8, the old Eloquent model classes have been completely replaced with class-based factories. With this, you can now manage the states of objects just using methods. These methods generally call the State() method, which is given in the base Laravel factory class. the State() The method takes as argument a function which will take into account an array of attributes assigned to the factory.

6. Improved maintenance

Previously, Laravel had an authorization list of IP addresses that you could use to access the application in maintenance mode. This has been removed and replaced with a simpler “secret” solution. You can specify the bypass token using the secret option.

In maintenance mode, you can access the URL of your application and Laravel will automatically pass the bypass cookie to your browser. Once the cookie is issued, you will access the application normally as if it were not in maintenance mode.

Your users may encounter errors if you are using PHP craftsman down during deployment. To avoid this, Laravel offers the option to display a maintenance mode view that will be returned whenever a request is made. You can pre-render a model using the command’s render option down.

7. Time test aids

Laravel now includes the ability to allow you to manipulate the current time. You have the option of using your time attributes in milliseconds, hours, days, etc.

public function testTimeCanBeManipulated()
{
// Travel into the future...
$this->travel(5)->milliseconds();
$this->travel(5)->seconds();
$this->travel(5)->minutes();
$this->travel(5)->hours();
$this->travel(5)->days();
$this->travel(5)->weeks();
$this->travel(5)->years();
// Travel into the past...
$this->travel(-5)->hours();
// Travel to an explicit time...
$this->travelTo(now()->subHours(6));
// Return back to the present time...
$this->travelBack();
}


These helper functions make your work neat and easy to follow by giving descriptive names to methods.

8. Improved flow limitation

Rate limiting allows you to manage the amount of traffic you receive on a certain route or group of routes. This can be achieved by using the accelerator middleware. Throttle middleware takes the name of the flow limiter you want to use on a route. An HTTP request code (429) is returned if the incoming request exceeds a given rate limit.

In Laravel 8, the flow limiter has been designed with more flexibility while maintaining backward compatibility. The rate restrictor callback feature allows you to dynamically create appropriate rate limits established on authenticated users or incoming requests.

Exciting times ahead for Laravel

Laravel is easy to learn and provides an extensive developer’s guide with easy-to-follow examples. It provides bug fixes and fixes almost every week and major releases every year (around September). If you need more help, Laravel provides the Laracasts platform where you can get expert help. However, the platform offers paid web development courses.

For a web developer, Laravel is an essential skill. It is open source, free and with a community of over 40,000 users. It is a technology that deserves to be followed.


frameworks-learn
5 web frameworks worth learning for developers

Interested in learning advanced web development? Avoid writing repetitive code — use these web development frameworks instead.

Read more


About the Author

Source link

About Irene S. Stroupe

Check Also

COD Adds Web Development Degree

GLEN ELLYN — The College of DuPage said Monday that it now offers an associate’s …