xpertlab-IOT
IOT-Internet of Things
26th March 2019
xpertlab-android-pie
Android P (Pie) V-9.0
1st April 2019

Laravel is a PHP framework that will drastically improve your productivity. It has been around for quite some time. The first version was released in June of 2011. However, the founder, Taylor Otwell, and his crew are actively improving it.

The latest version (5.7), only came out in September of 2018. It runs on PHP 7.1.3 and above. It follows the MVC (Model-View-Controller) pattern which allows for a much-needed separation of concerns in our web applications.

Features Of Laravel

Eloquent ORM (Object-Relational Mapping)

PHP’s implementation of the active record pattern. In simple terms, this pattern allows us to present database tables as classes. Instances of this class are tied to each row in the table. A bit confused? All this means is that you can define a class, e.g. User, which will be tied to the “users” table in your database. Each row in the “users” table is then represented as an instance of the User class. Simple.

Then to find a user in the database you can simply call User::find(1); where 1 is the unique id of the row in the users table. Eloquent obviously allows for more complex select queries.

Views With Blade

Views contain all of the HTML “code” served by your application. That way you don’t ever have to combine the business logic with the presentation layer. Views support Blade templating engine which allows you to write reusable pieces of HTML code as well as generic layout files. It becomes very useful when certain pages of your application consist of the same components, e.g. a footer.

It’s important to note that Blade templates must be saved with a .blade.php extension.

Controllers

Controllers allow for the grouping of related request handling logic into a single class.

Routing

A very simple routing mechanism with all the routes conveniently listed in one file is present. You can naturally have multiple files if you wish, especially if you have a bigger application that supports an API. Here’s an example of a route definition.

Route::get('profiles', ‘UserController@getProfiles');

Then you can use this route anywhere in any of your HTML forms (using Blade).

the routing mechanism will recognize the route and execute the code specified in the definition. In this case, Laravel will look for the UserController class and the getProfiles method.

Simple Authentication

Have you implemented a complete authentication mechanism with registration and login and then forgotten the password functionality in 10 seconds? No problem. Just run those two simple commands: 

  • php artisan make:auth
  • php artisan migrate 

Most web applications must implement an authentication system but why reinvent the wheel? With Laravel it comes for free.

Summary

There are many benefits to implementing web applications with Laravel but first and foremost it will save you a lot of time.

The key features are as follows:

  • Eloquent ORM
  • Blade Templating
  • Controllers
  • Routing
  • Quick Authentication