The Laravel framework has its latest version, Laravel 8. It was released on the 8th of September. Some amazing new features are present in it.
Additionally, it has a guide to upgrading. Taylor Otwell is behind the creation of Laravel. In his LARACON presentation, he has announced some of the new features.
Hire Laravel Developer if any of this is too difficult for you to understand. They can always help you build a web app. Laravel always stands out when it comes to web development.
PHP’s most popular framework is Laravel. PHP itself is one of the pioneer programming languages.
Laravel is also one of the most trending repositories on GitHub. It has almost 64.6k stars and counting.
After the release of features like Artisan (Command Line Interface), it has gained more popularity.
It provides support for the database system, migrations and bundles. Extremely well-known websites have Laravel as their foundation.
These are BBC, OnePlus, and 9GAG. Ranging from startups to enterprise-level, it is suitable for developing all kinds of web applications.
Laravel also comes with official packages that open up many possibilities. It comes with a lot of built-in functionalities that allow developers to work with ease.
Let us look into its previous features alongside talking about the new features. We will find out why it is attractive already.
1. App Directory
Laravel 8 will now be here with an app/models directory. We already know that in the previous version of Laravel, the root app directory was left by the model class.
Anyway, over 80 percent of developers were creating an app/models directory themselves, according to a poll run by Taylor. A PHP artisan makes: model is an artisan generator command.
If any such command is used by you, a model class can be created by it for you. it shall create a new model for you inside the new app/models directory.
You might want to keep your models in your app directory and delete the new model’s directory.
The generator commands comply with that and create the model classes in the app directory.
2. Brand New Landing Page
On a fresh install, the page you see when you visit the homepage has a completely new look. It is built with TailwindCSS.
This also comes in light and dark versions. Links to several community sites and various SaaS products from Laravel are present as well.
There is a link to the all-new Laravel shop as well over there if you would like to get your hands on some new match.
3. Namespace Prefix For Controllers Removed
There was a property in the RouteServiceProvider.php called $namespace in the earlier versions of Laravel.
This was used to prefix the namespace of the controllers automatically (applying AppHttpControllers).
Laravel would have double prefixed your namespaces if you were using the callable syntax in your web.php routes file. This particular property has been removed from Laravel 8.
Fortunately, you can now import your controller classes in your routes file without issue. Hire dedicated laravel developers who suit your budget.
4. Improvements On Route Caching
You were using the route caching in your application already hopefully. Running the command, PHP artisan route:cache generates a PHP file with an array that contains all the routes.
Laravel then uses this for routing because it is faster than having to parse your routes files on every request.
If you had any closures in your routes, however, or even if a package registered a route with closure, it would have caused the route caching to fail. You get support for route caching for closure-based routes with Laravel 8.
5. Attributes For Blade Component
Having a component called DangerButton can extend another component called Button. Say if you were to extend a blade component in Laravel 7, the child button would not have the attributes passed down to it.
All child components are supposed to have the attributes available in Laravel 8. This makes it very easy to build extended components.
6. For Closure-Based Event Listeners, Cleaner Syntax
While registering a closure-based event listener in previous Laravel versions, we would have had to define the event class firstly.
Secondly, we would have to register the closure. Then we probably would have to type-hint the event class for the closure.
You can skip the first definition of the event class in Laravel 8. This is since the framework is able to infer it from the type hinted at argument.
7. Anonymous Event Listeners Who Are Queueable
You will be able to send a closure-based job to the queue from your model event callbacks in Laravel 8.
It was not possible to make this happen until you created an event class and event listener using the ShouldQueue trait in previous Laravel versions. The new feature makes the process quicker.
It actually introduces the first namespaced function into the Laravel framework, IlluminateEventsqueueable.
8. Secret Access Introduced In Maintenance Mode
You can use the artisan down/artisan up commands to put the site into maintenance mode. Suppose, you still want to give access to some people (maybe yourself, or other developers, etc).
The only way in which this is possible is via IP whitelisting. It would not work well in two cases.
Firstly, if you were to grant access to lots of people. Secondly, suppose you have a dynamic address that changes regularly. Guess what?
This changes with the Laravel 8. Now, use a flag that says “secret”. You can do this when your site is put into maintenance mode. While your site is in maintenance mode, the value of the secret flag becomes a route.
Then, if you navigate to that, the framework sets a cookie. This particular cookie instructs your app to ignore the maintenance mode when it is accessed.
It lasts for several hours and gets redirected to the homepage of the app. You can then browse this as an absolutely normal website.
For Job Failures, We Have Exponential Backoff
A new backoff () method can be added to the job classes. This returns an array of integers in order to decide the acceptable wait time between job attempts in case it fails.
Hire Full Stack Developers who can cater to your website requirements.
Conclusion
Taylor and the team have been absolutely busy with several more features. It has been a while since the launch of the version.
Still, it is essential to shedding some light on the core features of Laravel 8. You can always watch Taylor’s talk or something similar in the Web Development Industry to keep yourself updated with everything that is going on.