Thursday 27 August 2020

What to Expect from Laravel 8?


Laravel 8 has got some amazing features for the Laravel Application Development Companies to help them create great apps leveraging such features.

The recent Laracon conclave was organized on Wednesday and it was conducted virtually (online) rather than the usual real-time summer conference in the US. Even though there were a total of 15 speakers, everyone was waiting to listen to that one talented speaker.

The new and unique features in the upcoming release of the framework were announced by Taylor Otwell, the creator of the Laravel framework. Before introducing a plethora of improvements with unique features, Taylor first started with smaller changes. These features have been updated and introduced on September 8th, 2020.

Below are some of the features that were announced:

1. Better Syntax for Event Listeners


While registering a closure-driven event listener you initially have to explain the event class then define the closure and maybe type hint which is the event alert for the closure.


Event::listen(OrderCreated::class, function(OrderCreated $event) { 
	// Do something here
});



You can skip past the first definition of the event class in updated Laravel 8 as the framework will easily interpret it from the type hinted command.


Event::listen(function(OrderCreated $event) { 
    // Do something here
});



2. Improved Landing Page


Now built with TailwindCSS, the page that you will see on clicking the homepage on your first install is a much-improved one. It has a facelift in light or dark shades. This new landing is synced with different Laravel products from different community sites as well as Laravel. If you are looking for some merchandise you can click on the link to the new Laravel shop.

3. Enhanced Route Caching


Assuming that you were already running route cache in your app. With an array of all your routes in it, running the PHP artisan route:cache creates a PHP file that is utilized by Laravel because it’s quicker than parsing your route file(s) on every request. However, until now, your route caching would have failed if there were any closures included in your route or a package entered a route coupled with a closure.

However, Laravel 8 supports the route cache process for routes based on closure. Hence, now you cannot make excuses not to be able to utilize route caching.

4. Maintenance Time: pre-rendered page


Your application will find a lot of errors even if you call for php artisan down command to display your website under maintenance when implementing your application. The auto-load doc is scripted as the dependencies change. It will display an error message before the visitors instead of displaying the maintenance mode window after running the Composer section of the deployment. This was the case in the earlier version of Laravel 7.

This is, however, not an issue in Laravel 8. As part of the artisan down command, your Laravel Development Company can now add the name of a view to a "render" flag.


php artisan down --render="errors::back-soon"


Laravel will preview the errors/back-soon.blade.php view and the site will be put under maintenance mode. The people trying to access the site will be facing a preview. Errors won't be displayed to their screen as the framework won't try to load the composer autoload file.


5. Default app/models directory


Unlike in previous versions of Laravel where a model class was left in the root app directory, Laravel 8 will now utilize an app/models directory. Statistics shown by Taylor show that the app/models directory were being created by developers themselves.

A new model will be created inside the new app/models directory if you utilize any of the commands generated by artisan like PHP artisan make:model. The generator commands will, however, create the model classes in your app directory if you want to store your models in it and delete the new models’ directory.

6. Blade Component Attributes


If a Blade component could be extended (like a component called DangerButton that extends another component known as a button) the $attributes wouldn’t have been passed down by the child button in Laravel 7. However, in Laravel 8, all child components will have attributes passed down to them which will be easier to build extended components.

7. Schema Dump


The Schema Dump feature is one of the most convenient features of Laravel and can be used easily with Laravel Voyager.

Your Laravel development services provider can prune all your existing migrations by first dumping your entire database schema and then by adding the --prune flag.

This will create a single schema dump file and erase all of your old migrations. If you have a lot of migration files this is the perfect way of erasing them all.

You can start after that by adding new migrations again and they will work normally. If you want to clear the migrations folder once you reach a specific number, you can update the schema:dump command again by running it.

8. Unique Access to Maintenance Mode


The only way to keep your website in maintenance mode and at the same time wish to let some select people access it by using the artisan down / artisan up command is by IP white listing. If you have a dynamic IP address or want to let many people access your website it does not work well as the IP is not stable. This is how Laravel 8 handles this issue. While putting your site into maintenance mode, you will now put a "secret" flag.


php artisan down --secret=let-me-in


While your site is in maintenance mode, this secret flag acts as a route. The framework creates a cookie if you can navigate to that and you can browse normally on your website when it redirects you to the landing page of your application.

9. Controllers Namespace Prefix Removed


$namespace was a property in the previous versions of Laravel in the RouteServiceProvider.php. It was used in the namespace of your controllers instantly to prefix them. Laravel may have dual prefixed your namespaces if you were utilizing in your web.php the callable syntax. You can import your controller classes without any issues in your route files as this property has been removed in the latest Laravel update.

Synopsis


Apart from these, there are many other improvements also introduced in Laravel 8. It is great to see Laravel strive hard to bring about improvement in almost every feature. If you plan to use Laravel for your future project, take the help of a Laravel Web Development Company to get the best out of this framework.

Author Bio :


Sanjay is a young entrepreneur who has energy, perfection, focuses, and highly self-motivated and goal-oriented professional with 12+ years of experience in Web Development, Web Services, and Software development with a proven track record in cross-platform execution and excellence in team development & leadership. He has the ability to decipher technology and make it profitable for business solutions. He is a core part of the think tank of World Web Technology Pvt. Ltd.




0 comments:

Post a Comment