


PHP is an open source server-side script development language that is popular at home and abroad. Able to adapt to the development needs of large, medium and small projects. In this article, we will introduce to you several mainstream PHP frameworks and their related advantages and disadvantages, and share them with friends as a reference.
Main reference PHP frameworks include: CodeIgniter, CakePHP, ZendFramework, Symfony. I have not used many frameworks seriously, I just tried them briefly. Many of my opinions may be immature or wrong. Please correct me and let us grow together.
CodeIgniter
Advantages:
1. Simple configuration, all configurations are configured using PHP scripts, and high execution efficiency; it has basic routing functions and can perform routing to a certain extent; it has preliminary Layout functions , can produce a certain level of interface appearance; the database layer is well encapsulated and has basic MVC functions
2. Fast and concise, not much code, high execution performance, simple PHP framework, easy to use, low learning cost, detailed documentation; self- It brings a lot of simple and easy-to-use libraries, and the framework is suitable for small applications
Disadvantages:
1. Simply understand the Model layer as database operations
2. The PHP framework is slightly simple and can only meet the needs of small applications, but is slightly less suitable. Meets 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 not bad, simple and efficient.
CakePHP
Advantages:
1. CakePHP is the PHP framework most similar to RoR, including the design method and the Active Record method of database operation; the design level is very elegant and does not come with extra libraries, all The functions are pure frameworks with good execution efficiency; the hasOne and hasMany functions of the database layer are very powerful and suitable for complex business processing; the routing function and configuration function are not bad; the automatic scaffolding (scaffold) is very powerful; suitable for medium-sized applications ;Basically implemented every layer of MVC; It has the function of automatically operating command line scripts;
2. The documentation is relatively complete, and it has been promoted successfully in China. Most of them know CakePHP, and the learning cost is medium
Disadvantages:
1. A very serious problem with CakePHP is that it understands Model as a database layer operation, which seriously affects its ability to operate other than the database. 2. CakePHP's cache function is slightly weak, and its configuration function is slightly weak; CakePHP is not suitable for large-scale applications, and is only suitable for large-scale applications. For medium-sized applications, the learning cost is slightly higher for small applications
Evaluation:
Generally speaking, the CakePHP framework represents a very important era and representative of the PHP framework, and it currently plays a very important role. Many people write it themselves All frameworks imitate the CakePHP method, which is a landmark product; CakePHP reveals RoR's agile development method and the design idea of considering database operations as the only model. It is an excellent tool for developing rapid applications and prototypes; similarly, using It is also worth choosing as a development framework for Web 2.0 websites.
Zend Framework
Advantages:
1. Official product, comes with a lot of libraries, the framework itself is written using many design patterns, the architecture is very elegant, and the execution efficiency is medium; in MVC design, compared It is simple, has routing function, the configuration file is relatively powerful (can handle XML and php INI), and the various libraries are very powerful. It is the most comprehensive function among all PHP frameworks, including that it is not only a PHP framework, but also a large category Library (replacing PEAR), this is its main feature; it can intuitively support the Model layer in addition to database operations (better than CodeIgniter and CakePHP), and can easily use the Loader function to load other newly added Classes; Cache function It is very powerful. It supports everything from front-end Cache to back-end Cache. The back-end Cache supports Memcache, APC, SQLite, files, etc.; the database operation function is very powerful and supports various drivers (adapters)
2. The documentation is very complete, in The domestic community is very mature, and is currently used by many Web 2.0 websites. The learning cost is medium
Disadvantages:
1. The MVC function is relatively weak, the View layer is simply implemented (the same as not being implemented), and the front-end page cannot be powerfully controlled
2. Without automated scripts, creating an application, including entry files, must be built manually, and the entry cost is high
3. Zend Framework is not a big problem as a medium-sized application framework, and it can barely be used as a PHP framework for large-scale applications. But as a very mature large-scale PHP framework, it still needs some effort
Rating:
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. Moreover, their development team is very strong and completely sufficient. It has the ability 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. Generally speaking, Zend Framework is the most anticipated PHP framework. Of course, there is no problem if you want to use it in your project now.
Symfony
Advantages
1. Symfony is the most powerful PHP framework I know, and I have been using it for a long time, but many functions are still not explored; it fully implements the three layers of MVC, Encapsulates everything, including $_POST, $_GET data, exception handling, debugging functions, data detection; contains powerful caching functions, automatic loading of Class (this function is very cool), powerful i18n nationalization support; has a very powerful view Layer operations can contain multiple files in pieces; very powerful configuration function, using yml configuration to control all frameworks and program running behaviors, so powerful that it makes people speechless; you can define various classes of your own at will, and symfony can These classes can be automatically loaded (auto load) and can be called at will in the program; including powerful multi-level project and application management: Project --> Application --> Module --> Action, which can satisfy multiple needs under one project. Application needs, and each layer can define its own class library, configuration file, layout; very powerful command line operation functions, including creating projects, building applications, building modules, refreshing cache, etc.;
2. Symfony is definitely a development tool The first choice for large and complex projects, because using Symfony will greatly save development costs, 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 database operation model uses heavyweight prop and creole, but in the version I tested, they have been moved to the addon. They can be used or not
2. The caching function cannot be controlled, and the total cost of every development and debugging is It is a cache. You need to execute symfony cc, symfony rc to clear and rebuild the cache;
3. The efficiency is not very high, especially the process of parsing templates and reading configuration files, which takes a lot of time;
4. The learning cost is high , and there is no mature community and documentation in China, not even a Chinese manual. Correspondingly, it takes a lot of time to master all the functions
Evaluation:
Symfony is definitely an enterprise-level PHP framework, the only one that can seemingly compete with Java What powerful frameworks can compete with the field? Powerful things are naturally complicated to learn, but they are also more helpful for project development. Naturally, it is recommended to use Symfony to handle complex projects. I think it is worth it. The later maintenance cost is relatively low and the complexity is Very useful. 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 Construct the model layer.
Summary
The above PHP frameworks each have their own characteristics, and they are all open source projects. However, the projects targeted by the frameworks are different. Generally speaking, CodeIngiter is more suitable for small projects, CakePHP and Zend Framework are more suitable for medium-sized projects, and Symfony is more suitable. For large-scale heavyweight projects, when selecting projects, you must fully consider the customizability and scalability of the framework, because each project cannot be sure whether you will make changes as the needs change.
Relatively speaking, Zend Framework and Symfony have a strong ability to cope with changes, especially the Classes in the model layer that can be customized at will. It is very convenient to add your own business or data processing classes. I personally recommend them for use in medium and large projects. PHP framework.
CodeIngiter and CakePHP can also play a significant role in small and medium-sized projects, rapid development and prototype construction, and are very suitable for the development of prototype projects with unclear goals.

php把负数转为正整数的方法:1、使用abs()函数将负数转为正数,使用intval()函数对正数取整,转为正整数,语法“intval(abs($number))”;2、利用“~”位运算符将负数取反加一,语法“~$number + 1”。

实现方法:1、使用“sleep(延迟秒数)”语句,可延迟执行函数若干秒;2、使用“time_nanosleep(延迟秒数,延迟纳秒数)”语句,可延迟执行函数若干秒和纳秒;3、使用“time_sleep_until(time()+7)”语句。

php除以100保留两位小数的方法:1、利用“/”运算符进行除法运算,语法“数值 / 100”;2、使用“number_format(除法结果, 2)”或“sprintf("%.2f",除法结果)”语句进行四舍五入的处理值,并保留两位小数。

判断方法:1、使用“strtotime("年-月-日")”语句将给定的年月日转换为时间戳格式;2、用“date("z",时间戳)+1”语句计算指定时间戳是一年的第几天。date()返回的天数是从0开始计算的,因此真实天数需要在此基础上加1。

方法:1、用“str_replace(" ","其他字符",$str)”语句,可将nbsp符替换为其他字符;2、用“preg_replace("/(\s|\ \;||\xc2\xa0)/","其他字符",$str)”语句。

php判断有没有小数点的方法:1、使用“strpos(数字字符串,'.')”语法,如果返回小数点在字符串中第一次出现的位置,则有小数点;2、使用“strrpos(数字字符串,'.')”语句,如果返回小数点在字符串中最后一次出现的位置,则有。

在PHP中,可以利用implode()函数的第一个参数来设置没有分隔符,该函数的第一个参数用于规定数组元素之间放置的内容,默认是空字符串,也可将第一个参数设置为空,语法为“implode(数组)”或者“implode("",数组)”。

php字符串有下标。在PHP中,下标不仅可以应用于数组和对象,还可应用于字符串,利用字符串的下标和中括号“[]”可以访问指定索引位置的字符,并对该字符进行读写,语法“字符串名[下标值]”;字符串的下标值(索引值)只能是整数类型,起始值为0。


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

SublimeText3 Chinese version
Chinese version, very easy to use

SublimeText3 Mac version
God-level code editing software (SublimeText3)

MantisBT
Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.

Dreamweaver CS6
Visual web development tools

DVWA
Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is very vulnerable. Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment, to help web developers better understand the process of securing web applications, and to help teachers/students teach/learn in a classroom environment Web application security. The goal of DVWA is to practice some of the most common web vulnerabilities through a simple and straightforward interface, with varying degrees of difficulty. Please note that this software
