The following is the translation:

The choice of which framework to use when developing your application depends on a number of factors. Like any application framework, the Laravel framework has its pros and cons. Those nasty drawbacks aside, in this article we will focus on the advantages of using the Laravel framework. Before I get into the magic of Laravel, I want to take a moment to discuss why we use frameworks to develop applications. What are the potential risks of developing everything you need to build an application instead of using an existing framework?

What’s wrong with building an application without a framework?

To understand the potential risks of developing an application without using a framework, let’s assume that we have to build an application that uses the MVC (Model-View-Controller) architectural pattern. When you start setting up an architecture, there are many architectural patterns to choose from, depending on the structure of your application. When I think about developing a complete application architecture myself, several questions immediately come to mind.

First, which component of the application should I start with? Do you install all third-party dependencies and libraries first? In terms of application extensibility, what model class libraries should I use to interact with the database? Should I use the PDO class, or is there a better option? How will I manage dependency injection? Given that there will be more developers working on the same application in the future, how do I keep a complete record of this architecture?

These questions may seem difficult to answer, but I want to tell you that they are just the beginning. Obviously, if you’re not a programmer familiar with the MVC architecture, then these questions themselves are new to you. If you haven’t used any framework before, you’ve probably never asked these questions. If this is the case, then that in itself is enough reason to adopt the Laravel framework for application development. The Laravel framework will handle all of these low-level details for you and provide you with a concise and practical architectural pattern. At the same time, the Laravel framework handles the seamless interaction between the model, view, and controller for you. It will also provide you with many different features built into the framework so that you can focus on writing the business logic of your application. As a result, you save a lot of time and effort by not having to spend time looking for solutions to these low-level problems.

The framework provides consistency and flexibility

Let’s try to imagine a situation where you are developing a large application, but you are not using any existing framework or using a framework you built yourself. As the number of users increases or more features need to be added, you will need more developers to develop and maintain the application. In addition to introducing new developers to all of the software development processes and methods that your development team needs to follow, you must also explain to them the entire structure of the application that you’re building.

For this reason, new developers must go through a high learning curve to understand the new architecture you are developing. But if you use the Laravel framework, this problem will disappear, because the framework will give you consistency in application development. The Laravel framework is well documented, and new developers do not have to go through the learning process of using the new framework. You can easily hire a developer who is familiar with the Laravel framework and get him to work quickly.

When a team builds applications using a standardized framework, such as Laravel, it becomes easy to add other developers to the team. This is because: when you hire a developer who is familiar with the Laravel framework, he can understand the code because all the code follows the same pattern.

Benefits of using the Laravel framework

If all of this sounds interesting enough to encourage you to use frameworks for your next application, let me share some of the advantages the Laravel framework offers over other PHP frameworks. These advantages certainly make the Laravel framework one of the main contenders for the best PHP framework.

1. User authentication out of the box

The Laravel framework provides user authentication out of the box. Any modern Web application requires user authentication, and with the Laravel framework, you need to do almost nothing to set it up. When you set up user authentication, the Laravel framework creates all the important components, such as the user model, the registration and login controllers, and the corresponding views. It is also very easy to extend these components to new functionality in the future, depending on the business logic required by the application.

In addition, the Laravel framework provides Socialite Package (an extension package), which enables your application to authenticate users using various social networks such as Facebook, Google Plus and Twitter. You only need the minimum configuration to make it work.

2. Convention over Configuration (also known as programming by convention)

The Laravel framework also takes a “convention over configuration” approach. This basically means that if you follow the naming conventions of different components, you have little to no need to worry about configuration. If you follow the naming conventions, the Laravel framework itself takes care of a lot of the low-level details for you, and everything starts working magically. If you’ve been using traditional PHP programming, this can be overwhelming at first. But once you get a taste, you never want to look back.

3. Easy to use email

It’s hard to imagine a modern application without email. Using the Laravel framework, it is very easy to implement the email sending function. In addition to SMTP and Php mail capabilities, the Laravel framework supports a wide variety of email notification services such as Mailgun, Mandrill, SparkPost, Amazon SES, SendMail, and many more. These services allow you to quickly start sending email via local or cloud-based services. You can also use Nexmo to send notifications via Slack and SMS. All of these services are available out of the box in the Laravel framework.

The Laravel framework also supports Markdown in email templates, which allows you to create emails in a fraction of the time.

4. The Artisan command

For me personally, the Artisan command line is the most concise and useful feature provided by the Laravel framework. Artisan is the command line interface for the Laravel framework, which helps developers automate many tasks using the command line itself. The Artisan command can be used within the application itself, and developers can also create additional Artisan commands.

For every common task you can think of, there’s an Artisan command for it. For example, create a model, create a controller, create a database seed, migrate the database, and so on. The list is endless. I call it “concise” because all you have to do is pass commands, and the Laravel framework does the rest.

5. Test automation for TEST-driven development

The Laravel framework comes with support for PHPUnit, making it easy to test PHP applications that use test-driven development. It’s easy to write unit tests for your application and make sure things work the way you want them to.

6. Simple dependency injection

Once you start working with the Laravel framework, you quickly realize that the Laravel framework takes its inspiration from Ruby on Rails and more functional languages, not From Java. This can be easily seen in the way the Laravel framework handles dependency injection. While implementing DEPENDENCY injection can take a complex pattern, the Laravel framework takes the opposite approach and provides a simple way to create global helper functions. With global functions and the Faade static proxy, we can easily implement dependency injection wherever we need it.

7. Separation of business logic and display code

Laravel follows the model-View-controller (MVC) architectural pattern, separating the business logic from the view. This approach has many advantages. To really understand its benefits, you need to understand what the MVC pattern is and whether your application needs such an architecture.

8. Eloquent ORM (Object-relational Mapping) implementation

Eloquent is Laravel’s ORM (object-relational mapping) implementation. For more information, see the wikipedia link (en.wikipedia.org/wiki…) . Eloquent Makes it very easy to get data from a database. It is also easy to create relationships between tables and get data from those tables. Eloquent also allows you to create a variety of connections in tables, and provides a host of helper functions that make interacting with databases very simple. You rarely need to write SQL queries or functions. Using the Eloquent ORM, The Laravel framework provides out-of-the-box support for the following databases:

MySQL

PostgreSQL

SQLite

SQL Server

Absolutely. This basically means you don’t have to worry about compatibility with any of the above databases as long as you use the Eloquent. Switching from one database to another is also very easy. Now try to imagine the extensibility that this brings to your application, and let me illustrate this with an example. Suppose you have an application that starts with a very small user base. Since the number of users is small and the application is in its infancy, you decide to use MySQL as your database. Over time, the number of users of your application has grown to a fairly high level, and now you may need to switch to a SQL Server database. Thanks to using the Eloquent, this toggle is now as simple as changing specific configuration details in the Laravel framework.

9. Queue and Scheduler

When developing an application, there are often time-consuming tasks. These tasks need to be deferred to a later time so that they do not block the user’s process. A perfect example of such a task might be to generate a PDF report that counts user requests to create a CSV file. The Laravel framework’s queue service provides a uniform API for defering these tasks to later in the application.

Speaking of the Command scheduler of the Laravel framework, it is a perfect substitute for those tedious, scheduled tasks. In many cases, developers must set up scheduled jobs for specific tasks. A perfect example of such a task would be to send out the weekly Newsletter to all subscribers to which they subscribe. To set up this scheduled job, the developer must log in to the server using the SSH command and set up the scheduled job at the operating system level. This can be a problem for some time because these scheduled jobs cannot be part of GIT and other version control systems administration. But the Command scheduler of the Laravel framework uses built-in functions to provide a clean API for scheduling a wide variety of tasks. This way, you don’t have to use SSH to log in to the server terminal, and all of these scheduled jobs become part of the code and are managed by the version control system.

10. Concise routes

The Laravel framework handles routing in a simple and intuitive way. There is a single web.php file that handles all web routing. If certain routes require common middleware, they can easily be grouped in Laravel.

A perfect application scenario for routing would be pages in an application that require user authentication before the user can view them. The Laravel framework groups all these pages and Auth middleware checks to ensure that only users logged in to the system can view them. The Laravel framework also provides a neat Route Model Binding, where models can be bound to routes. With this help, the view can return directly from the route itself, without even needing to access the controller.

11. Composer manages dependencies

The Laravel framework uses Composer to manage dependencies and automatic loading. Composer helps you install Laravel extension packs, making dependency management a breeze. At any time, you can check the package.json file to see all the dependencies your application is using. Composer also lets you update dependencies with a single Composer command.

12.Blade template engine

Blade is the template engine for the Laravel framework. Blade gives you a head start in separating views and business logic. It keeps your view code very clean. Once you have a clear understanding of the MVC architectural pattern and Laravel’s implementation of it, the importance of the Blade template engine will become much clearer. Blade also provides template inheritance, so you can divide a recently used template into parts and have other view files inherit those parts. With Blade, you can create smaller sections of a view that are logically smaller and can then be included to form a complete view.

13. Documents

This is a bit of a gray area. When I first started using the Laravel framework, I did have problems finding documents. Everything was undocumented, but at one point I suddenly realized that something was working magically, and that’s when people started following the naming conventions. There are now API documents that list every class and method declared in the Laravel framework. Once you have mastered how to use it, and know how to use Laravel documents to your advantage, I guarantee you won’t have any more complaints.

14. Active community

Laravel does have an active community. When you run into any problem, you can search, and you’re sure to find a lot of StackOverflow posts for your problem. In addition to having an active community on StackOverflow, there is also a discussion forum called Laracast. You can sign up for free to be part of the Laracast forums and community, which is very active right now.

I think these advantages are enough to get you excited about the Laravel framework. While it’s certainly an exaggeration to call it perfect, I can say for sure that the Laravel framework is definitely one of the best PHP frameworks out there.

Source: baijiahao.baidu.com/s?id=164425…