Home >Backend Development >PHP Problem >Should PHP development use a framework?

Should PHP development use a framework?

(*-*)浩
(*-*)浩Original
2019-09-25 09:15:494058browse

There are also frameworks in php, such as thinkphp and brophp which are commonly used in China. Laravel abroad. But there are also pros and cons of using it, the analysis is as follows:

Should PHP development use a framework?

The framework is very good, it can make the decision more coherent. The framework can prevent us from writing a lot of custom modules to achieve these functions. All we need to do is to implement these common modules in the framework. Frameworks save us a lot of time and effort and make extensions easier. But this is also the root of the problem.

To a hammer, everything is a nail (Recommended learning: PHP programming from beginner to master)

Abraham Kaplan There is a saying that can best accuse the shortcomings of tools: Give a hammer to a child, and he will use the hammer to hammer everything he encounters

This is the time to measure whether you are more professional, and deliver it to the future Scale the best code instead of shipping the easiest to implement. Whether to better design your code for future needs or let others consider it when they meet the needs in the future, this is a question of the programmer's sense of responsibility. As a more professional developer, we must think independently without relying on frameworks.

This is your fault

Do you often hear someone complaining about a certain framework?

I've heard a lot of people complain about Rails: "Rails applications are always poorly structured" or "Rails tests are always so slow."

At first, I thought so too. But now, every time I hear these complaints, I realize that the complainers are actually lazy. Rails, or any other framework, is just a tool, you control it. Blaming bad code on an inanimate framework only shows your unprofessionalism.

Choose the right tool, or use the tool correctly

Decide to become more professional

We must base our decisions on basic Choose tools based on your needs. The framework can indeed do a lot of things, and requirements will determine the entire code structure. Sometimes a framework is a good fit for a certain need. But when the framework does not suit certain needs, you have the responsibility to modify the framework or encapsulate the framework for clarity and cleanliness of the code.

The author Myles Megyesi’s thoughts at the end of the article mentioned that the framework is just a tool. You cannot use this tool to meet all your needs. When the framework cannot clearly and completely meet your needs, you What you need to do is not to write a lot of junk and troublesome code to realize the requirements, nor to modify your requirements to make it easier to implement.

As a more professional you, you need to modify the framework, or use abstraction and other thinking to make your code clear and clean.

This will be encountered a lot in actual development. When someone asks you: Why is the code here written like this?

If your answer is: No way, because this is how the framework does it, I can only do this.

This shows that you have been bound by the framework. Don't think that the framework is authoritative. The framework is written by others, and it does not take your needs into consideration when writing it. As long as your needs are the common needs of the team and need to be modified, when adding a framework, you should modify the framework.

Code is meant to be read and developed more clearly and naturally. If it is tied to a framework, it is actually putting the cart before the horse.

The above is the detailed content of Should PHP development use a framework?. 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