The advantages and disadvantages of the seven frameworks commonly used in PHP

无忌哥哥
Release: 2023-04-03 06:32:01
Original
9648 people have browsed it

Text content

For a long time, what has been most discussed in phper is the advantages and disadvantages of various php frameworks. The information on the Internet is also relatively scattered. Now I have collected and summarized several mainstream frameworks, of which I have only used them. There are four frameworks: Yii2, Laravel, Yaf, and Thinkphp. Therefore, most of the evaluations of various frameworks come from online information. If you have any questions, please point them out in the comments and make progress together

1. ThinkPHP

ThinkPHP (FCS) is a lightweight medium-sized framework, which is a Chinese PHP development framework transplanted from Java's Struts structure. It uses object-oriented development structure and MVC mode, and simulates the implementation of Struts tag library. It is more user-friendly in all aspects. It is relatively easy for developers familiar with J2EE to get started, and it is suitable for beginners of PHP framework. ThinkPHP's purpose is to simplify development, improve efficiency, and be easy to expand. Its database support already includes support for MySQL, MSSQL, Sqlite, PgSQL, Oracle, and PDO. ThinkPHP has rich documentation and examples, and the framework has strong compatibility, but its functions are limited, so it is more suitable for the development of small and medium-sized projects.

Advantages

1. With the help of mature Java ideas

2. Easy to use, rich Chinese documentation; low learning cost, high community activity

3. The framework has strong compatibility, PHP4 and PHP5 are fully compatible, fully supports UTF8, etc.

4. Suitable for the development of small and medium-sized projects

5.Introducing composer package management tool from thinkphp3.2.2

Disadvantages

1. Ajax The support is not very good;

2. The directory structure is confusing, which is a little worse than that of other frameworks;

3. It is easy to get started, but difficult to learn in depth.

2. Yii

Yii is a high-performance component-based PHP framework for developing large-scale Web applications. Yii is written in strict OOP and has complete library references and comprehensive tutorials. From MVC, DAO/ActiveRecord, widgets, caching, hierarchical RBAC, web services, to theming, I18N and L10N, Yii provides almost everything needed for today's Web 2.0 application development. In fact, Yii is one of the most efficient PHP frameworks.

Advantages

1. Pure OOP

2. Used for large-scale web applications

3. The model is easy to use

4. Develop quickly and run quickly. Excellent performance and rich features

5. Use command line tools.

6. Support composer package management tool

Disadvantages:

1.Less guidance and consideration of the Model layer

2.Fewer document examples

3. Too much English

4. Requires proficiency in PHP technology and proficiency in OOP programming!

5. View is not an ideal view. The ideal view may be just html code and will not involve PHP code.

3. Laravel

Advantages

1. Laravel’s design idea is very advanced and is very suitable for applying various development models TDD, DDD and BDD

2. Support composer package management tool

3. It integrates relatively new features of PHP, as well as various design patterns, Ioc containers, dependency injection, etc.

Disadvantages

1. Based on component-based framework, so it is relatively bloated

4. CodeIgniter

Advantages:

1.Code Igniter advocates the principle of "simplicity is beautiful". There are no fancy design patterns, no fancy object structures, everything is so simple. It only takes a few lines of code to start running, and a few more lines of code to output. It can be said to be a model of "great simplicity".

2. The configuration is simple, all configurations are configured using PHP scripts, and the execution efficiency is high;

3. It has basic routing functions and can perform routing to a certain extent;

4. Has preliminary Layout function and can create a certain level of interface appearance;

5. The database layer is well encapsulated and has basic MVC functions.

6. Fast and concise, the code is not Many, high execution performance,

7. The framework is simple, easy to use, low learning cost, and the documentation is detailed;

8. It comes with many simple and easy-to-use libraries, and the framework is suitable for small applications.

Disadvantages:

1. The implementation itself is not ideal.

2. The internal structure is too confusing. Although it is simple and easy to use, it lacks expansion capabilities.

3. Simply understand the Model layer as a database operation.

4. The framework is slightly simple and can only meet the needs of small applications, but is slightly less able to meet the needs of medium-sized applications.

Evaluation:

Generally speaking, it is worthwhile to use CodeIgniter to complete simple and fast applications. At the same time, it can construct a certain degree of layout to facilitate the reuse of templates. The data operation layer is well encapsulated, and CodeIgniter It does not use many too complex design patterns, and the execution performance and code readability are both good. As for the additional library, it is also pretty good, simple and efficient.

5. Zend Framework

Advantages:

1. A large number of new object-oriented features in PHP5 are applied: interfaces, exceptions, abstract classes, SPL, etc. The application of these things makes Zend Framework highly modular and flexible

2. Strictly follow the principles of "programming for interfaces" and "single object responsibility"

3.Officially produced, self-produced It brings a lot of libraries, and the framework itself uses a lot of design patterns to write. It is very elegant in architecture and has medium execution efficiency.

4. MVC design, relatively simple

5. It has routing function. The configuration file is relatively powerful (can handle XML and php INI)

6. It can intuitively support the Model layer in addition to database operations (stronger than CodeIgniter and CakePHP), and can easily use the Loader function to load other Newly added Class

7. The Cache function is very powerful. It supports everything from front-end Cache to back-end Cache. The back-end Cache supports Memcache, APC, SQLite, files, etc.

8. The database operation function is very powerful and supports various methods. A kind of driver (adapter)

9. The documentation is very complete and it is very mature in the domestic community

Disadvantages:

1. The MVC function is relatively weak, and the View layer is simple to implement (similar to Not implemented), unable to powerfully control the front-end page.

2. Without automated scripts, creating an application, including the entry file, must be built manually, and the entry cost is high

3. For simple and small projects, on the contrary, because a large amount of object-oriented design is applied in the framework, higher requirements are put forward for developers, which indirectly increases the development cost of the project.

Evaluation:

As an officially produced framework, Zend Framework’s ambitions are foreseeable. It wants to crowd out other frameworks and at the same time encapsulate many powerful class libraries to provide one-stop framework services. Their development team is very powerful and completely It is capable enough to develop very powerful products, so it is basically certain that Zend Framework has a bright future, if more time is spent to improve the framework. Similarly, the Zend Framework architecture itself is relatively elegant, which shows that Zend officially has many experts and is relatively advanced in design concepts. Although some functions are not fully implemented, such as the View layer, automation scripts, etc., these all depend on the future. Upgrade

6. CakePHP

Advantages:

1. The framework most similar to RoR, including design method and Active Record method of database operation

2. The design level is very elegant, there is no extra library, all functions are pure frameworks, and the execution efficiency is not bad

3. The hasOne and hasMany functions of the database layer are very powerful, and are relatively suitable for complex business processing Suitable

4. Routing function, configuration difficulty is moderate

5. Automatically build scaffolding (scaffold) is very powerful, suitable for medium-sized applications

6. Basically implemented every MVC First level

7. It has the function of automatically operating command line scripts

8. The documentation is relatively complete and the learning cost is moderate

Disadvantages:

1.CakePHP is very The serious problem is that the Model is understood as a database layer operation, which seriously affects the ability to operate other than the database

2. The cache function is slightly weak

3. The configuration function is slightly weak

4. Not suitable for large-scale applications, only suitable for medium-sized applications. The learning cost is slightly higher for small applications.

Evaluation:

In general, the CakePHP framework represents PHP The framework is a very important era and representative, and it currently plays a very important role. Many self-written frameworks imitate the CakePHP method, which is a landmark product; CakePHP reveals RoR’s agile development method and regards database operations as It is the design idea of ​​the only Model, and it is an excellent tool for developing rapid applications and prototypes; similarly, it is also worth choosing as a development framework for Web2.0 websites

7. Symfony

Advantages:

1. Completely implements the three layers of MVC

2. Encapsulates everything, including $POST, $GET data, exception handling, debugging functions, and data detection

3. Contains powerful caching function

4. Automatically loads Class and can freely define various classes of your own

5. Powerful language support

6 .It has very powerful view layer operations and can contain multiple files in a piecemeal manner

7. Very powerful configuration function, using xml configuration to control all frameworks and program running behaviors

8. Contains powerful multi-level project and application management: Project --> Application --> Module --> Action, which can meet the needs of multiple applications under one project, and each layer can define its own class library and configuration file , layout

9. Very powerful command line operation functions, including creating projects, creating applications, creating modules, refreshing cache, etc.

10.Symfony is definitely the first choice for developing large and complex projects. Because of the use of Symfony, development costs will be greatly saved, and there will be no problems when multiple people collaborate. After defining the basic Class at the Project level, any module can be reused, greatly reusing code.

Disadvantages :

1. The biggest problem is that too many open source projects with different styles are used to combine into a framework

2. Since Mojavi and Propel themselves are quite complex, the structure of Symfony is very complex , difficult to understand and learn

3. The cache function cannot be controlled. Every time development and debugging are always cached, you need to execute symfony cc, symfony rc to clear and rebuild the cache

4. The efficiency is not very high , especially the process of parsing templates and reading configuration files, which takes a lot of time

5. The learning cost is very high, and there is no mature community and Chinese documentation in China

Evaluation:

Symfony is definitely an enterprise-level framework, the only thing that can seemingly compete with the powerful frameworks in the Java field. Powerful things are naturally complicated to learn, but they are also helpful for project development, so they are naturally recommended for complex projects. It is worthwhile to use Symfony to handle it. The later maintenance cost is relatively low and the reusability is very strong. Correspondingly, if you use Symfony for more complex Internet projects, you must consider the issue of database distribution. Then you need to abandon the database operation layer that comes with Symfony and define it yourself. Of course, Symfony supports arbitrary Constructing the model layer

Overall comment:

The above frameworks have their own characteristics, and they are all open source projects. However, the projects targeted by the frameworks are different. Generally speaking:

1. Small projects: CodeIngiter

2. Medium-sized projects: CakePHP, Zend Framework, Laravel, Thinkphp

3. Large-scale heavyweight projects: Yii, Symfony, Laravel

The above divisions are not absolute. When selecting projects, you must fully Consider the customizability and extensibility of the framework, because each project cannot be sure whether you will make changes as your needs change

The above is the detailed content of The advantages and disadvantages of the seven frameworks commonly used in PHP. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template