Skip to content

Laravel 5 New Features For The PHP Developers

Laravel

At present, Laravel is more popular than other PHP frameworks. As an open source framework, Laravel enables developers to speed up web application development without increasing project overheads. It scores over other frameworks in the categories of performance and scalability. Also, it simplifies modern web application development by providing robust features like Eloquent ORM, authentication library, events, queues, caching, route caching, Blade template engine, route middleware, and native security features. Each new version of Laravel also comes with several new features and enhancements to meet the emerging trends in web application development. The web developers can always use Laravel 5 to avail an array of new features.

Brier Overview of 12 New Features in Laravel 5

1) Redesigned Directory Structure

Laravel 5 comes with a redesigned directory structure. It makes each class fully namespaced by implementing PSR-4 autoloading standard. The default namespace for the web applications is app. However, the programmers can change the default namespace through a command. They can further manage the application environment and environment elements efficiently through the.env file stored in the root of the project.

2) Method Injection

The version 5 of Laravel simplifies method injection significantly. It does not require programmers to request the Inversion of Control (IoC) container to provide a class instance. The developers now have option to declare the type hinted class instance in the controller method’s signature. They can even include multiple parameters in the controller method’s signature. The IoC container will automatically handle the type hinted class instance automatically.

3) Route Caching

Laravel 5 speeds up route caching by taking advantage of the route caching feature of Artisan. The feature boosts the performance of the PHP application significantly by speeding up its route registration. However, the performance improvement can be notices only if the application has a large number of routes. The developers also have option to turn the route caching feature on or off by running specific commands.

4) Route Middleware

Laravel 5 allows developers to add extra layers to the HTTP routes using middleware. The programmers include specific code in the middleware class, and execute the code before specific routes in the application. They can further append the middleware to @middleware array through the specific file. Also, they have option to add middleware to specific routes in the application.

5) Contracts

Most of the core components of Laravel 5 use contracts. As a set of interfaces, contracts define the core services. Also, they make the components loosely coupled by removing class dependencies. The programmers can also use contracts to simplify package development. Laravel 5 has the capability to identify the implementation of individual contracts automatically.

6) Authentication

Laravel 5 enables PHP developers to perform authentications without writing authentication boilerplate. It provides database migrations, models, views, and controllers by default. The developers simply have to configure the database migrations, models, views, and controllers to implement the desired authentication. At the same time, they also have option to take advantage of a ready to use authentication service provided by the web framework.

7) Events

The version 5 of Laravel allows programmers to use event objects. Hence, the developers are no longer required to declare application events as strings. They can use simple commands to create both event objects and event handler objects. They can further fire the events directly through specific commands. Also, the event and event handler classes will be stored in specific but separate folders.

8) Command Objects

Laravel 5 allows developers to encapsulate business logic into command objects. It further allows developers to run the business logic asynchronously in the background by queuing the command objects. As self-contained code, command objects further help programmers to perform unit testing continuously. However, the developers must not include large chunks of code in controller actions to perform unit testing smoothly.

9) Multiple File Systems

The version 5 of Laravel provides native support to multiple files systems. However, it implements multiple file system support through the third party package Flysystem. Flysystem makes it easier for developers to create PHP application with local or cloud storage simply by changing the default configuration. Also, it simplifies working with the filesystem façade by performing the underlying storage operations automatically. The developers have option to configure the storage options and access the available storage options in the project.

10) Queue and Task Scheduling

Laravel 5 comes with a ready to use queue by default. The queue does not require programmers to use any third-party packages additionally. The developers can simply configure the default queue provided by the PHP framework to schedule various tasks efficiently. They can store all queueable jobs in a single folder and execute the jobs by creating queueable commands. Also, Laravel 5 allows programmers to schedule tasks with a single cron entry.

11) Request Object

The request object feature of Laravel 5 makes it easier for Laravel programmers to inject data validation logic, authentication, or authorization into requests. They can inject the authentication or authorization after implementing business logic in the request object. Also, they can simply type hint the authentication/authorization into the controller’s action. Hence, the controller action will not be executed if the validation rule fails.

12) Socialite

Laravel 5 allows programmers to integrate third-party social media authentication into the web application through Socialite. The social media authentication interface provided by Socialite does not require programmers to write additional boilerplate social authentication code. The developers can use Socialite to authenticate with Facebook, Twitter, Google or Github. However, they have to integrate Socialite into Laravel through compose, and configure the providers according to precise need of the web application.

The PHP web developers can also avail several new features by using version 5.1, 5.2, 5.3, or 5.4 of Laravel. Each new version of Laravel comes with an array of new features to simplify and speed up PHP application development. Also, the newer versions of web framework extend the features provided by Laravel 5. Hence, it becomes essential for programmers to keep track of the new features provided by the latest version of Laravel. The programmers also need to use the most recent version of the Laravel to avail additional features.