Is the PHP framework usually used in small projects? SegmentFault

Source: Internet
Author: User
Tags redis cluster
What should we do for large projects? No framework. All of them are hand-written films? PHP is not required. In other languages? What should we do for large projects? No framework. All of them are hand-written films?
PHP is not required. In other languages?

Reply content:

What should we do for large projects? No framework. All of them are hand-written films?
PHP is not required. In other languages?

I hesitated to answer this question. This is a frequently asked question during the interview, because every framework is different from every project, selecting a framework is a matter of experience and thinking and judgment.

The project size is only a basis for decision-making, or even a basis of little importance. Next, let's talk about what I think should be paid attention to when selecting a framework.

Team members & Future team members & local career market conditions

First, if you are the only one in the present and future of the Team (for example, your toy project), you can select the one you want most. But if this is not the case, you 'd better first understand the common frameworks on the market and then forget your personal preferences.

Learn about the current situation of your team members, consider the future development speed of your team, the potential of future team members, and the status of your local career market. For example, Laravel may be a good choice, but if you are in the second and third-tier cities, the team must develop rapidly to attract a large number of people, choosing Laravel may soon bring you into the "composer and modern PHP skills training courses" dilemma. Teaching is a great career, but not your career.

Project lifecycle & Future Evolution

This is one of the factors that I think are much more important than the project size. Some projects, as your company's main business, require long-term maintenance and continuous iteration. Other projects may be used as corner and transition projects, and there may be no subsequent requirements after completion. Finally, there are some outsourcing/outsourcing projects. After delivery, there will be no need/follow-up needs to be another project.

There are more large projects and more demands. If there is a third type, you do not need to consider the future evolution, then the scalability of the framework will be sacrificed (in exchange for development speed or other benefits ), for example, you can choose to change wordpress. For a small project, if your company's main business is continuous iteration, you must carefully consider the scalability of the framework even if the workload is small.

So what is the scalability of the framework? Is ci a Well-scalable framework? Is ZendFramework1/2 a framework with good scalability?

The answer is, looking at the future evolution. In the future, some projects are under heavy access traffic, some are under heavy data volume and frequent retrieval, while some are under fast iteration of demands, frequent changes, and short cycles. The more common the problems faced by the project, the less repetitive the framework of Preset solutions. The more extreme the problems faced by the project, then the lightweight frameworks may be more suitable for your team to study their own solutions and graft them into the frameworks. In addition, the longer the project maintenance time, the harder it is to predict changes, the larger the risk of adopting a framework with preset solutions (the smaller the probability that preset solutions can solve each of your problems)

Basic Qualities of the framework itself

Performance and running score. Except for the two C implementation frameworks of phalcon and Yaf, other frameworks should be considered as fast. In addition, unless you host something like changing the PHP framework on Sina Weibo, Or you manage more than 100 project web machines, ignore the performance factors of the PHP framework.

This API is compatible with composer. This is a double-edged sword. I have already talked about how to look at this feature.

Security. Some frameworks even have their own security vulnerabilities. In addition, if some security aspects are provided at the framework level, it is recommended that you simply read the code. Sometimes it may be better to write it yourself.

Functionality. That is, the number and quality of Preset solutions have been mentioned earlier.

Degree of modularization. Can each part of the framework be customized? What is the cost of customization.

Business Code volume (?) It is difficult to find the corresponding word. In short, the third feature is the same as the first two (functional & modular), and the three cannot achieve both. A framework with many features and a high degree of modularity that can be customized and replaced at will often write a bunch of Common Business Code. A framework that can write a lot of functions in one sentence is often not ideal in modularity and is not easy to customize. A framework with a high degree of modularization and no wordy business code often has no rich preset functions.

The surrounding ecosystem, activity level, and compatibility. There is still room for growth and improvement in an active framework. However, if the framework is too active, application compatibility may fail. Another indicator is the surrounding ecosystem. Is there anyone else who develops Peripheral modules/plug-ins based on this framework.

Finally, if you must use the rough words "big" and "small" to describe the framework and project, I suggest using a small framework for large projects and a large framework for small projects. If you understand what I mentioned above, you should be able to understand why I said so.

Small projects use some popular frameworks or something.
Large projects write their own frameworks. Some mature frameworks will also be used to remove unnecessary functions or optimizations.
If you want to learn thinkphp first, then laravel and Phalcon.

Small Forum PunBB and big Forum Discuz! There are no PHP programs using the framework. It can be seen that the framework is not necessary for the project.
PHP itself is a Web framework that separates the interface and logic and implements MVC. For example:
Front-end:

/Post. php? Id = 1024 // page controller (processing input, calling model, integrating data, and output view)/include/common. php // execute some public operations and load the public database ). /config. php // global configuration/include/functions. php // system functions (model, SQL addition, deletion, modification, and query, pre-processing of parameterized queries to prevent SQL injection)/themes/default/functions. php // topic UDF/include/database. php // connect to the database on demand/themes/default/post. php // view (htmlspecialchars/HTMLPurifier prevents XSS)/themes/default/header. php // public header (common. js)/themes/default/footer. php // public tail

Background:

/Admin/post. php // page controller (process input, call model, integrate data, and output view)/include/common_admin.php // execute some public operations and load the public database (linking up and down ). /config. php // global configuration/include/functions. php // system functions (model, SQL addition, deletion, modification, and query, pre-processing of parameterized queries to prevent SQL injection)/admin/themes/default/functions. php // background theme User-Defined Function/include/database. php // connect to the database/admin/themes/default/post as needed. php // view (htmlspecialchars/HTMLPurifier prevents XSS)/admin/themes/default/header. php // public header (common. js)/admin/themes/default/footer. php // public tail

The bigger the project, the more framework is required to unify thoughts and norms. Otherwise, there will be a large number of developers working on different things. How can this problem be solved? Only the framework itself chooses to be developed by itself, or the issue of choosing to use the existing source framework.

Medium-and large-sized instances have no pressure at all, but they are not suitable for ultra-large instances. Suitable for medium-sized, medium, and large application development

I don't know in your eyes, Baidu post is not a big project. It has been using php before it was migrated to hhvm,

Not to use, but to use it. However, the frameworks of large companies are not necessarily those well-known outside. Baidu, for example, is extended according to Yaf,

Depending on the situation, PHP is indeed suitable for small and medium-sized projects, because PHP has a short development cycle and high efficiency. However, large companies will also choose

Using PHP, such as Sina Weibo, he has the ability to improve PHP. Some people have the ability to write PHP high-availability extensions, which can bring the PHP performance to the extreme.

Then, with Nosql, high concurrency can be completely put above mysql. At present, Weibo's Redis cluster is very large, with many

Operations cannot go to the database operation layer, and are solved in Re/mc. Therefore, PHP is used for any project depending on the team.

PHP capabilities.

Large projects use php as well. If you look at a framework that can be called an enterprise-level development framework, You can generally develop large projects. Of course, this large project depends on the specific size of your project.

A framework can be used for small, medium, and large projects! If conditions are met, try to use the framework.

Since so many frameworks have been written by others, do not repeat the wheel, but learn how to use it.

Learn some important frameworks, such as Symfony, Yii, Phalcon, and Laravel,
These frameworks are used in many major projects. Of course, if you participate in medium and large projects in the future, you may also be exposed to them,
Learning and using them now paves the way for the future!

A heavyweight framework involves many things and helps you to learn more about PHP.

Https://github.com/lloydzhou/router

What is a project? What is a big project? Generally, a large project is divided into several small projects. These "Small Projects" have their own languages and frameworks,

Regardless of the size of the project, the basic performance bottleneck is not in php, unless you deliberately write very bad, even so php is extremely fast.
Most of the bottlenecks are in databases.

Related Article

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.