How to choose the right PHP framework for you

Source: Internet
Author: User
Tags php framework smarty template yii
This article mainly introduces the content is about how to choose the appropriate PHP framework, has a certain reference value, now share to everyone, the need for friends can refer to

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

PHP is widely used in large projects, such as Facebook's use of PHP to build and maintain their internal systems. WordPress uses PHP as its kernel to make it occupy 26% of Web projects. Currently 82% of Web sites use PHP as their server-side development language (according to web tecnology Surveys website survey)

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

Why use the PHP framework?

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

    • The PHP framework makes the development process faster, for example, you don't have to write complex query statements to query data from the database. The PHP Framework provides CRUD operations (create creation, read read, update updates, delete delete)

    • Framework makes it easier for developers to extend systems

    • Easier to maintain than normal PHP application code. Application code is more streamlined and easy to operate

    • The MVC model guarantees rapid development

    • For common security threats, the framework can better protect the security of application Web applications

    • Don ' t repeat yourself (don't repeat) principle to ensure the most effective use of minimal code

The above benefits are so significant that they cannot be overlooked. Even using native PHP can be used to develop any application, but current development specifications require tools and time management techniques to meet the needs of the market.

How to choose PHP Framework

Answering some of the questions below will help you choose the right frame for you:

    1. What are the features and functions of this framework? (Does it provide my needs?) )

    2. Is this framework easy to learn?

    3. Can this framework extend the line strength?

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

    5. Does this framework provide long-term support?

    6. Is there a strong community support for this framework?

Symfony, Laravel and Yii

Before we delve into the details of the technology, let's start with the overall introduction of these 3 competitors.

Symfony

Symfony is a reusable set of 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 RAD environments. 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, the most popular framework Laravel is also based on Symfony.

Laravel

Laravel is widely used as a "framework for Web artists", providing a very good community and the title of the most popular framework.

In May 2015 Laravel issued a statement that the Laravel5.1 version will provide 2 years of long-term support. Launched in November 2015 with the 5.2 release. Many hosting providers offer Laravel support and provide managed solutions for Laravel applications.

Yii

Qiang Xue introduced the Yii framework in 2008, and the YII framework is safe, fast and performance-efficient. Yii uses composer as its PHP dependency management tool to help handle different dependencies and its installation. Due to the use of lazy loading technology, the YII framework is currently the fastest frame.

Another great feature of Yii is the integration of jquery. This integration allows 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 3 frameworks develop Web2.0 applications that are very good, but each serve with different purposes. Let's look at their characteristics and their current state.

Template engine

The template engine simplifies the work of the developer and provides better functionality when writing front-end code. The template engine provides features such as automatic HTML code escaping and filtering, and fill the gaps left by native PHP.

Symfony Twig Template System

Twig is a modern template system for PHP. Symfony uses the Twig advantage to enable developers to write cleaner, more concise code.

See the Twig website to learn more about Twig features

Laravel Blade Template System

Unlike other templating systems, Blade lets you use PHP code in the view. And the performance impact of blade on applications is almost zero, because view files are all .blade.php as extensions. View files all the code is converted to native PHP during the program's run.

Yii Default Template system

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

There are no obvious winners here. The 3 frameworks use the template engine to make the writing and maintenance of the front-end code easier. One small advantage of yii is that it does not pre-preset a templating system.

Frame different points

Each frame is different. Symfony is committed to providing reusable components and providing the best modularity support. Symfony also uses models and controllers to develop Web applications, which may seem like a cliché for new developers. But it does. Symfony is a good example of a modular framework. You can use the 30 components provided by Symfony in your project using a modular approach.

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

Symfony can be used to quickly develop and use complex projects. Even if there is a dispute over which framework is best suited for developing complex projects, Symfony shows superior complexity with respect to other frameworks

Yii also uses components but not as modular as symfony. Laravel does not offer aggressive modular support like the other 2 frameworks.

If you are looking for a modular framework, choose Symfony, other words, laravel and yii are good choices.

Installation

These three frameworks provide a number of installers. If you use composer to handle the installation package, you will be pleased to find that all the frameworks can be installed through composer

For Symfony, the role of composer is even more critical. By using the Phpcomposer dependency manager, the idea of component processing can be better implemented.

There are other mounting options for each frame. For example, you can use a simple archiving method to install the framework.

After the installation is complete, YII provides you with a Web application and a basic template to work with. Symfony2 also provides a starting demo program.

The laravel can be composer create-project easily installed through composer commands 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 defeat competitors.
Symfony has a strong society to support and is highlighted as a robust framework. Laravel is growing fast, but Laravel still has a long way to go before it is seen as a practical development option for PHP.
On the other hand, if you don't know any PHP framework and want to get started quickly, consider Laravel. Laravel has a simple learning curve and you will find many tutorials on the web to help you get started.
Yii has a new level of performance and provides code scaffolding for rapid code generation and development.

Performance

The performance of any application is only related to whether it is a real-time application that uses critical data. How many high-performance Web applications are dependent? Not many, but the performance of the framework can play a key role in many projects.

Social networking is a prime example of real-time event applications, and one of our star's products-jadson uses YII2 to build a mobile social network, when we chose the best framework for writing high-performance applications. Yii is highlighted as the fastest PHP framework.

The performance of Laravel is a controversial issue. It's the slowest, but does it matter? You'll find online resources to speed up its performance, including the guidelines on GitHub to make your Laravel app 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.

Community and Resources

An important predictor of the sustainability of open source frameworks is the power of their communities. These 3 frameworks have a stable and solid community, although the Symfony community may be more mature, but the community is evolving, so dynamic predictions of the future of the community are difficult.
When it comes to learning materials and documentation, Laravel highlights, although Symfony and Yii are not much behind.

Scalability

Frameworks are structures that can be extended by extension or package to improve their functionality and scope. When it comes to expansion, Laravel is the winner. Packalyst a Laravel Expansion pack library provides more than 9000 expansion packs. 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.

Same point

We have studied the differences between frames. Now let's look at their similarities:

    • The 3 frameworks are all-stack PHP frameworks, from front-end code writing to post-segment data acquisition, providing the ability to build Web applications

    • Projects are open source and hosted on GitHub, making it easy for anyone to contribute their code

    • All frameworks have good documentation comments and are supported by a large community

    • All support ORM (Object relationship Mapping). ORM is ideal for writing object-oriented code for your application.

    • Robust, secure and reliable for developing Web2.0 applications

Still confused? Perhaps these lists will help you narrow down your selection:

Symfony:

    • Long-term support version available

    • With a lot of features

    • It is currently the most stable framework

    • Component-based framework for scalable, modular functionality

    • Strong community support and a wealth of learning resources

YII:

    • Born with Ajax support

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

    • Highly scalable

    • Powerful error handling

    • Facilitates the development of RESTful style Web services

    • Strong community support and a wealth of learning resources

Laravel:

    • The most popular framework

    • Support for composer Management expansion packs

    • Unit tests are doing well.

    • Provides a number of expansion packs to extend the functionality of the framework

    • Strong community support and a wealth of learning resources

Conclusion

In the competition between Symfony and Laravel and Yii, 3 frameworks are a great choice, providing developers with a full stack of development environments. For me, as a new and non-stop sign of the star-laravel is a winner.

This article is a translation document--The original link

Related recommendations:

How Redis is used in PHP framework CodeIgniter

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.