Laravel framework features

Laravel is the most favourite PHP framework of many developers when it comes to custom Laravel development. Laravel frameworks’ working makes it easy to implement authentication and provide a user friendly and clean API. Also, it supports the popular cache backends like Redis/Memcached.

In the process to make it better, the framework releases updates every six months to fix all the issues and increase efficiency of the web development process. The latest version of Laravel was released on 26th February 2019 and it also brought along some amazing set of features.

We have given you a brief introduction of the Laravel framework. Now, let’s talk about the Laravel framework features that have been introduced in version 5.8.

Carbon 2.0 Support


Latest version of the framework supports Carbon 2.0 making it easier for the developers to work with date and time. Carbon 2.0 has a new Date facade with a CarbonImmutable class. This class enables a user to make a copy of the original information and modify the copy without making alterations in the original piece of information. You can use this feature via the AppServiceProvider.

To create a copy of any date and make use of the Data facade, a Laravel developer has to update the ‘\routes\web.php’ file.

Hashed Tokens


It is not always compulsory to use the Laravel passport for authentication of Laravel API. But, most people are not aware of this fact. A user friendly ‘token guard’ can provide you the basic API authentication. Such facility is available in all versions upto Laravel 5.7. However, the 5.8 version has an additional facility which allows the storing of tokens as SHA-256 hashes.

This feature will render a higher level of security while storing the tokens.

Automatic Policy Resolution


In Laravel, ‘Policies’ are used to handle the user authorization. Policies are considered as ‘Classes’ which organize the authorization logic around a particular model. Things changes with the latest release. Now it is not necessary to manually register policies in AuthServiceProvider. One of the Laravel frameworks benefits is that it can automatically discover the policies.

Yet it is essential for the model and policy to stick to the standard Laravel naming conventions. For this feature to function, it is equally important for the ‘policy directory’ to be in the default location.

Inclusion of HasOneThrough Relationship


This feature is already present in the Rails framework. The inclusion of ‘HasOneThrough’ relationship will bring a certain level of efficiency in the development of web applications. For instance, if a User model has one Profile model and Comment model has a User then the Laravel developers can make use of this feature to get the profile for any given comment.

Cache TTL Modification


In the earlier version of this framework, caching was set in minutes. One of the advantages of Laravel framework’s latest version is that it allows a precise setting of expiration time while storing the items. Caching is set in seconds in this version.

For example, the command ‘Cache::put(‘foo’, ‘bar’, 30)’ will store the item for 30 seconds instead of 30 minutes.

Such a simple yet important modification will enable compliance with PSR-16 caching library standard.

Laravel framework features

Improvement of Artisan Serve


Earlier versions of the framework didn’t allow users to serve multiple applications. Improvement in Artisan serve freed the developers from the limitations earlier versions had. The drawback in earlier versions was that if one ‘serve’ command is running on port 8000, then it will become impossible to serve another application on this port.

In the newer version, ‘PHP artisan serve’ command can scan for an available port upto ‘port 8009’ allowing the users to serve multiple applications simultaneously.

Improvement of Artisan Call


The latest version of the framework makes it possible for a user to make ‘Artisan’ commands from the code using ‘Artisan::call’ method. In this case, the users can pass the options in one string instead of passing them as an array like in previous versions.

Scheduler Timezone Configuration


In Laravel, you can use the ‘timezone’ method to define ‘timezone’ for a scheduled task. In the earlier versions, this method needs to be repeated for every scheduled task. It became a tiresome task when multiple tasks are to be scheduled.

The newer version will liberate you from this tiring process. You can define the ‘scheduledTimezone’ method in your ‘app/Console/kernel.php file’ and return to the default timezone. This simple process will attach the ‘timezone’ to every scheduler, saving time for you on repetition of tasks.

Where Method or Higher Order


In earlier versions of the framework, it was necessary to use the ‘or’ query operator to combine the model scopes. This method made the ‘Closure’ callback necessary. The latest release brought a ‘higher order’ ‘orWhere’ method allowing to put the ‘scopes’ together without using the Closures.

Mock & Spy Methods


The ‘mock’ and ‘spy’ methods have been included in the base Laravel test case class in the new Laravel version. These methods will automatically bind the ‘mocked’ class in the container allowing to create cleaner codes.

Conclusion


We prepared a comprehensive Laravel framework features list to show you how the latest version has made Laravel development a lot efficient and quicker and the life of Laravel developers a lot simpler!


ABOUT THE AUTHOR
blog CMO - kodytechnolab

Drashti Pandya

PHP Developer


RELATED POSTS