Home  >  Article  >  Backend Development  >  How to choose the php framework that suits you

How to choose the php framework that suits you

不言
不言Original
2018-04-16 14:36:452563browse

The main content of this article is about how to choose a PHP framework that suits you. It has a certain reference value. Now I share it with you. Friends in need can refer to it

PHP is the most popular in the world One of the programming languages, and the recent release of PHP7 makes this server-side programming language more powerful and stable than ever.

PHP is widely used in large projects, such as Facebook using PHP to build and maintain their internal systems. WordPress uses PHP as its core and accounts for 26% of web projects. Currently 82% of web websites use PHP as their server-side development language (according to Web Tecnology Surveys)

In this article, we will analyze the 3 most popular PHP frameworks: Symfony, Laravel , and Yii. We help you choose a framework that best suits your needs by explaining how to compare them.

Why choose to use PHP framework?

What makes us use frameworks instead of using pure PHP native language to develop our applications? Some of the benefits of using a framework are as follows:

  • PHP framework makes the development process faster, for example, you don’t have to write complex queries to retrieve data from a database. The PHP framework provides CRUD operations (create, read, update, delete)

  • The framework makes it easier for developers to expand the system

  • Easier to maintain than ordinary PHP application code. The application code is more streamlined and easy to operate

  • MVC model ensures rapid development

  • For common security threats, the framework can better Protect the security of web applications The above benefits are too significant to be ignored. Even native PHP can be used to develop any application, but current development norms require the use of tools and time management skills to meet the needs of the market.

  • How to choose a PHP framework
  • Answering some of the following questions can help you choose a framework that suits you:

What are the features and functions of this framework? (Does it provide what I need?)

Is this framework easy to learn?

  1. Is this framework scalable?

  2. Is the core team of this framework actively developing and maintaining it?

  3. Does this framework provide long-term support?

  4. Does this framework have strong community support?

  5. Symfony, Laravel and Yii

  6. Before delving into the technical details, let’s first introduce these three competitors as a whole
  7. Symfony

  8. Symfony is a set of reusable PHP components that enable developers to develop easily scalable and high-performance applications. With 30 components to choose from, developers have complete freedom to experiment and work in the RAD environment. Symfony's APIs also make it easy to integrate with third-party applications, and it can also be used with popular front-end frameworks, such as AngularJs.

Many popular projects including Drupal and phpBB also use the Symfony framework. In fact, Laravel, the most popular framework currently, is also built on Symfony.

Laravel

Laravel is widely used as a "framework for web artists". It provides an extremely excellent community and has won the title of the most popular framework.

In May 2015, Laravel released a statement that Laravel 5.1 version will provide 2 years of long-term support. Version 5.2 was launched in November 2015. There are many hosting providers that provide Laravel support and provide hosting solutions for Laravel applications.

Yii

Qiang Xue launched the Yii framework in 2008. The Yii framework is safe, fast and has excellent performance. Yii uses Composer as its PHP dependency management tool to help handle different dependencies and their installation. Thanks to the use of lazy loading technology, the Yii framework is currently the fastest framework.

Another great feature of Yii is the integration with JQuery. This integration has led front-end developers to embrace it, and it uses scaffolding to generate code, similar to Symfony. Yii also uses components to quickly develop applications.

How to compare them

These three frameworks are very good for developing Web2.0 applications, but they each serve different purposes. Let's take a look at their characteristics and their current status.

Template engine

The template engine simplifies the work of developers and provides better functionality when writing front-end code. Features provided by the template engine include automatic HTML code escaping and filtering, and filling gaps left by native PHP.

Symfony Twig Template System

Twig is a modern template system for PHP. Symfony takes advantage of Twig to enable developers to write cleaner and more concise code.

See the Twig website to learn more about twig's features

Laravel Blade Template System

Unlike other template systems, Blade lets you use PHP in your views code. And Blade has almost zero impact on application performance, because view files all have

.blade.php

as the extension. All code in the view file is converted to native PHP during program running.

Yii Default Template System

Yii does not use any third-party template system by default, but this does not mean that it lacks support for template engines. The choice of template engine depends on the development team. Yii recommends using Twig and Smarty template engines. Symfony uses Twig, so if you have used Symfony before, you may want to use Twig in your next Yii framework.

No clear winner here. All three frameworks use template engines to make front-end code writing and maintenance easier. A small advantage of Yii is that it does not have a preset template system.

Differences in frameworks

Each framework is different. Symfony is committed to providing reusable components and providing the best modular support. Symfony also uses models and controllers to develop web applications, which may seem a bit old-school to new developers. But it's really useful. Symfony is a great example of a modular framework. You can use the 30 components provided by Symfony in your project using a modular approach.

Yii framework uses the MVC model (Symfony also provides support for MVC)

Symfony can be used for rapid development and complex projects. Even though there is debate about which framework is best for developing complex projects, Symfony has shown superior complex processing capabilities compared to other frameworks

Yii also uses components but is not as modular as Symfony. Laravel does not provide radical modularity support like the other two frameworks.

If you are looking for a modular framework, choose Symfony. Otherwise, Laravel and Yii are good choices.

Installation

These three frameworks provide many installers. If you use Composer to handle installation packages, you will be happy to find that all frameworks can be installed through Composer

For Symfony, Composer plays an even more critical role. By using the PHPComposer dependency manager, the idea of ​​component processing can be better realized.

There are other installation methods for each framework. For example, you can install the framework using the simple archive method.

After installation, Yii provides you with a web application and a basic template to work with. Symfony2 also provides a starting demo program.

Laravel can also be easily installed through Composer’s composer create-project command or through the Laravel installer. Please see the laravel installation guide for details.

rapid development

From a company or customer perspective, it is important to quickly bring applications to market to meet consumer demand and beat competitors.
Symfony has a strong community to support it and stands out as a robust framework. Laravel is growing rapidly, but it still has a long way to go before it can be considered a de facto development option for PHP.
On the other hand, if you don’t know any PHP framework and want to get started as soon as possible, then you can consider Laravel. Laravel has an easy learning curve, and you'll find many tutorials online to help you get started.
Yii takes performance to a new level and provides code scaffolding for rapid code generation and development.

Performance

The performance of any application only relates to whether it is a real-time application using critical data. How many web applications rely on high performance? Not a lot, but the performance of a framework can play a key role in many projects.

Social networks are the preferred example of real-time event applications. One of our star products - jadson, built a mobile social network using yii2. When we were choosing the best framework for writing high-performance applications. Yii stands out as the fastest PHP framework.

Laravel's performance is a controversial issue. It's the slowest, but does it matter? You'll find online resources to speed up its performance, including guides on GitHub to make your Laravel applications faster.

Database support

Symfony 2 provides better database support. You can use a set of databases, including NoSQL and DynamoDB.
Yii and Laravel are equally useful in this regard, but they support fewer databases than symfony. The databases supported by each framework are shown in Table 1.

How to choose the php framework that suits you

Community and Resources

An important predictor of the durability of an open source framework is the strength of its community. All three frameworks have stable and solid communities. Although Symfony's community may be more mature, the community is evolving, so it is difficult to predict the future dynamics of the community.
When it comes to learning materials and documentation, Laravel stands out, although Symfony and Yii are not far behind.

Extensibility

Frameworks are structures that can be extended through extensions or packages to improve their functionality and scope. When it comes to extensions, Laravel is the winner. packalyst is a laravel extension package library providing over 9000 extension packages. On the other hand, Yii and symfony provide about 2800 extensions and 2830 packages respectively, and Laravel provides more than 3 extensions. Laravel seems to be the best framework in this regard.

Similarities

We have looked at the differences between frameworks. Now let's look at their similarities:

  • The three frameworks are all full-stack PHP frameworks. From front-end code writing to back-end data acquisition, they all provide the function of building web applications

  • The projects are all open source and hosted on GitHub, which makes it easy for anyone to contribute their own code

  • All frameworks are well documented and documented A huge community supports ORM (Object Relationship Mapping). ORM is great for writing object-oriented code for applications.

  • Robust, secure and reliable enough for developing Web 2.0 applications

  • Still confused? Maybe these lists will help you narrow down your choices:

  • Symfony:

Provides long-term support version

  • With a lot of Features

  • It is currently the most stable framework

  • A component-based framework that provides scalable modular functionality

  • Have strong community support and rich learning resources

  • Yii:

Born with ajax support

  • Because it provides faster operations, it is the best choice for developing real-time applications

  • Highly scalable

  • Powerful error handling

  • Conducive to developing Restful style Web services

  • ##Has strong community support and rich learning resources

  • Laravel:

The most popular framework

  • Supports Composer management extension package

  • Unit testing is well done

  • Provides a large number of extension packages to extend the functionality of the framework

  • It is powerful Community support and rich learning resources

  • Conclusion

    In the competition between Symfony vs. Laravel vs. Yii, the 3 frameworks are all excellent choices, all for development Provides a full-stack development environment. For me, as an emerging star that shows no signs of stopping - Laravel is a winner.
This article is a translated document--original link

Related recommendations:

How to use redis in the php framework CodeIgniter

The above is the detailed content of How to choose the php framework that suits you. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn