Laravel: an Efficient Web Application Development Framework
Total Page:16
File Type:pdf, Size:1020Kb
Journal of Information and Computational Science ISSN: 1548-7741 Laravel: An Efficient Web Application Development Framework Deepak Mehta Assistant Professor, Mandsaur University, Mandsaur [email protected] Abstract PHP is considered as one of the most popular scripting languages to be used in developing web applications due to the fact that it is dynamic, provides a large amount of flexibility, it is easy to use and is easy to learn. PHP frameworks come into the picture to help developing web application smoother and faster by providing a template basic structure, along with a completed set of built-in APIs, libraries and numerous of extensions. In other words, frameworks can speed up developing process, cut off developing time, and help developers be more productive by reducing repetitive code in the project. In recent years, there are many PHP frameworks for developers to choose. The developers should know how to choose the most suitable framework with the best support features to use in their project. This paper reviews a popular framework of PHP Laravel. This study shows the best features provided by the Laravel framework and compares it with other peer frameworks. Keywords: PHP framework, Laravel, Symfony, MVC. 1. Introduction Laravel is an open source PHP web framework introduced by Taylor Otwell in 2011.since its inception Laravel has become much mature in features. Laravel has built-in support for authorization and authentication. It provides tools for HTML template, routing, testing, database interaction etc. [1]. Laravel supports many best features of other famous frameworks like CodeIgniter, Yii, and other programming languages like Ruby on Rails, ASP.NET MVC, and Sinatra [ii] which makes it powerful and rich in functionalities. Laravel architecture follows MVC (model-view-controller) architecture pattern. In the MVC architecture, an applications code is organized into three main components: Volume 9 Issue 12 - 2019 1293 www.joics.org Journal of Information and Computational Science ISSN: 1548-7741 Figure 1: MVC Architecture Source: https://www.upwork.com/hiring/mobile/laravel-framework-php-programming/ Model: This component handles business logic and application data. It can be used to store data in different data source like files, database, XML document or other data source. Model in larval is created inside app folder. View: This component presents data to the user. It is user interface to which user interacts. It may contain HTML and CSS code. Controller: It is server side script which receives input from user interacts with appropriate model and retrieves data from model format it and present it to view. All these features make architecting an application in Laravel much faster than architecting from scratch. This makes Laravel a popular framework for quick PHP application development. 2. Laravel Application Structure Larvel provides default application structure but there is no constraint how you organize your application and where your classes are located. Root: root directory contains various files and folders:- App: this directory contains core code of application Bootstrap: This directory contains applications bootstrap framework scripts. Cache: this directory contains laravel framework auto generated configuration files to optimize performance of bootstrap. config: config directory contains application’s configuration files. Database: this directory contains database seed classes to seed your database with test data. Public: This directory is the starting point of your application, It contains controller and it starts the laravel application. It also contains CSS, JavaScript, images and other files. Resources: this directory contains applications view, language file templates and other files for styling application. Storage: this directory and its subdirectories stores log files which tracks errors and exceptions, cache and views that are used frequently. Volume 9 Issue 12 - 2019 1294 www.joics.org Journal of Information and Computational Science ISSN: 1548-7741 Tests: this directory contains various test cases for unit testing. The App Directory: App directory contains various files and folders to include source code of project. It has directories such as Console, Http, and Providers. Consol: It stores various commands. Events: events directory contains event classes to handle events generated by laravel application. Excpetion: contains methods and classes to handle exceptions. Jobs: It contains queueable jobs. Listeners: It contains event handler classes for events generated by application. Policies: this directory contains authorization policy for your applications. 3. Growing Popularity of Laravel Figure 2: Popularity of Laravel Source: https://trends.google.com/trends Google trends show the popularity of Laravel over other PHP frameworks. Laravel has 51192 stars on Github. Laravel is taking over in popularity because of its great features that makes web development simple, expressive, easier and faster. Laravel works on modular basis and provides a lot of pre-built functions to fast development process. Implementing authentication system Login, Registration, Password in Laravel is extremely easy [3].Laravel has well designed tools that allow Laravel writes less code. Volume 9 Issue 12 - 2019 1295 www.joics.org Journal of Information and Computational Science ISSN: 1548-7741 Figure 2: Popularity of Laravel in platforms category Source: https://webspotter.io/tech/laravel According to webspotter Laravel is third most used in platforms category. 4 Reasons for Popularity of Laravel AUTHORIZATION TECHNIQUE: When developing an application authentication is most important aspect. Laravel makes the implementation of authentication techniques very simple. Almost everything is configured extraordinarily. OBJECT-ORIENTED LIBRARIES: Laravel has many pre-installed object-oriented libraries which has many advanced features, such as checking active users, Bcrypt hashing, password reset, Cross-site Request Forgery, protection, and encryption. PHP framework: ARTISAN: Artisan is built-in command line tool. It Provides many helpful commands to create and handles the Laravel project environment. In addition to the commands listed in Artisan, a user can also create a custom command which can be used in the web application. It includes commands for managing database migrations, package assets, generating and seeding boilerplate code for migrations, models and new controllers. It makes the developers free from developing proper code skeletons [4]. Blade Template: Blade is powerful and easy to use built-in template engine for Laravel framework. Blade template engine has its own control structure such as conditional statements and loops. MVC SUPPORT: Another reason which makes Laravel the best PHP framework is it supports MVC Architecture like Symfony, ensuring clarity between logic and presentation. MVC helps in improving the performance, allows better documentation, and has multiple built-in functionalities. Here’s how the MVC works for Laravel [5]. SECURITY: Security Using Laravel reliable techniques are very easy. As a password will never be saved in the form of a simple text in the Database. A token is always Volume 9 Issue 12 - 2019 1296 www.joics.org Journal of Information and Computational Science ISSN: 1548-7741 generated when a user logs-in which is not a hacker to get the unauthorized access of the web page. [4] 5. Comparison with Peers Parameter Laravel Symfony Yii Code Laravel follows MVC Symfony use MVC Yii has no default Organization architecture for web architecture to develop template engine. Yii uses applications web applications. PHP as its template development. It uses Symfony uses Twig language, but you can Blade template engine, Templete Engine configure Yii to support which is its own which is an open other rendering engines, template engine. source product such as Twig or Smarty available as extensions.[5] Validation No scenario based The Symfony Yii has scenario based validation is available in Validator component, validation. Yii also default package of which provides a Provides client side Laravel. It does not wider range of general (JavaScript) validation of provide any construct to validation services, the form. You need to validate a model at performs the operation define only one set of different scenarios. You via the instantiation of rules of the model for have to code everything a Validation class, validation in server side yourself effectively validating a and client side. model on the OOP basis. Database Microsoft BI Apache Jackrabbit Microsoft BI Support MongoDB CouchDB MongoDB MySQL DynamoDB MySQL PostgreSQL GemFire GraphDB Oracle Redis MemBase PostgreSQL SQLite MemCacheDB SQLite Microsoft BI MongoDB MySQL NoSQL Oracle PostgreSQL Documentation Laravel has strong well Symfony has great Yii has great community explained community with lot of with lot of resources. Volume 9 Issue 12 - 2019 1297 www.joics.org Journal of Information and Computational Science ISSN: 1548-7741 documentation. learning resources. It has great community and tons of packages for extending framework functionality. Its tutorial covers everything from A to Z. 6 Conclusion Laravel is the largest used PHP framework in recent times and offers you numerous features to choose from. If you are trying to build a large scale web application or an enterprise grade app then Laravel is the best choice you can make. It has lot of built functions to save programmer’s time for example routing, view, query builder and