Home  >  Article  >  PHP Framework  >  Drupal compares with thinkphp to see the domestic open source environment

Drupal compares with thinkphp to see the domestic open source environment

青灯夜游
青灯夜游forward
2021-09-29 19:50:042847browse

Today this article will give you a comparison between ThinkPHP and Drupal, through which you can see the current status of the Chinese and foreign software industries, and the domestic open source environment!

Drupal compares with thinkphp to see the domestic open source environment

Housing, marriage, medical care, education, and elderly care are each a big mountain. "Making money" must be the top priority. Who has time to work on open source? Therefore, ThinkPHP, created by only two core developers, has become the hope of many people. On the other hand, there is no "programmers who only eat youth food". At open source software community gatherings, we often see people in their fifties and sixties still smiling in their eyes. Talking about technology, they look for the meaning of life and are not too disturbed by their livelihood. They inject their life's accumulation into open source. They dream that what they do can illuminate the world and transform their lives into great works that will be passed down to human civilization. So Drupal was praised by everyone and quickly sailed towards the sea of ​​​​stars. This article tells a sad story, thinking about where people who read the same text should go. This story should be known to more people.

Compare ThinkPHP and Drupal to see the current situation of the Chinese and foreign software industries

Putting ThinkPHP and Drupal (translated into Chinese as "water drop") together to talk will make many developers Readers are curious, but from the perspective of the development of Chinese and foreign software ecosystems, this is really a good starting point for discussion. This article has made some comparisons between the two systems in various aspects, but the comparison is not the main purpose of writing this article. It is mainly to share information between China and foreign countries. The differences in the software industry, and some of the thoughts caused by them, help developers plan their careers and provide decision-making basis for IT decision-makers.

Both systems are open source, free PHP applications. Let’s give a brief introduction first:

ThinkPHP:

Product positioning: PHP development framework, developers can continue to develop and build their own application systems on this basis

Development organization: developed by the domestic "Shanghai Dingxiang Information Technology Co., Ltd."

Founder: Liu Chen, there is not much information. Baidu Query is a senior consultant for open source software, a senior PHP programmer, and CEO of Kanyun. He has more than 15 years of experience in Internet product development and management. His main research areas include Web application architecture and development, and product user experience design. , committed to the domestic open source industry

Development time: first born in early 2006

Open source protocol: Apache 2

Official website address: http://www.thinkphp.cn /

User group: China's domestic small and micro enterprises, which have a high reputation in the domestic developer circle. Its official website describes itself as "the most influential PHP framework and pioneer in China!"

Famous cases: 56 Group, Lenovo Wenba, CYTS Happy Travel, Pocari Sweat, Starbucks, Metersbonwe’s Bangou Mall, TCL’s online mall, Sina WeChat, Aoxing, CRRC You Technology and others

Team size: There is no official data, but each file of the framework has author information. According to this statistics, there are a total of 7 people, including two main developers (contributing more than 90% of the code). These The data does not include developers who contributed to the community ecosystem. According to the query results of Dingxiang Company on the Qichacha platform, the company size is less than 50 people and the number of insured persons is 3. System file: According to the current 6.0.7 Counting versions, the number of initially installed files is 569 and the space occupied is 2.41MB

Drupal: Product positioning: complete back-end system (back-end system) End data and control center), used for back-end development of APPs, small programs, websites, Internet of Things, etc.

Development organization: a non-profit open source community co-constructed by more than 200 countries around the world and organized by the Drupal Foundation

Founder: Originally initiated by Dr. Dries Buytaert from Belgium. Dries’s 2008 university doctoral thesis was "Java Application Performance Analysis and Optimization Analysis Technology". James Gosling, the inventor of Java, He is a member of his doctoral defense committee. Dries’ personal homepage address is https://dri.es/about

Development time: first born in 2000

Open source agreement: GPL 2.0

Official website address: https://www.Drupal.org/

User groups: enterprises, government agencies, universities, individuals, etc. from all over the world, among which the market share of the world's top 500 companies exceeds 80%. Famous IDE: phpstorm directly integrates the new Drupal project

Famous cases: Domestic: Huawei, JD.com, Baidu, Tencent, Tsinghua, Peking University, Guizhou Municipal Government Station Group, Zhenkongfu, etc.; foreign: Tesla , Google, Honda, Qualcomm, United Nations, European Union, Harvard University, MIT, Disney, NASA, Pfizer Pharmaceuticals, etc.

Team size:

has the largest and most active open source community in the world, There are more than 1,800 core developers and more than 120,000 active contributors (code, documentation, designers, etc.), including more than 2,000 people in the Chinese sub-community, and the main driving company Acquia has more than 1,100 employees. Currently, an average of about 1,300 code submissions are generated per week.

System files: Based on the current 9.1.7 version, the number of initially installed files is 18,770, occupying 71.2MB of space

Why ThinkPHP and Drupal:

One is a popular framework in China, and the other is a complete back-end system that is popular internationally (it is also the most powerful and flexible system in the world, no one). Judging from their size, they are not in the same weight class at all. From the perspective of its market positioning, there is no comparison meaning, but exploring them is of great significance to understanding the Chinese and foreign software ecology. In addition, what if I directly tell you that Drupal can do everything ThinkPHP can do, and it is more elegant and concise? Things are getting interesting now, let’s continue.

Usually domestic developers who use Drupal are development veterans with many years of experience. They have come out of various systems step by step with the times. They must know or understand ThinkPHP to some extent, but developers who use ThinkPHP But they don’t necessarily know Drupal. The reason why developers who use ThinkPHP choose ThinkPHP is generally that the framework provides a common foundation further than the underlying PHP, is flexible and free, and is not restricted compared to secondary development of systems like Imperial CMS. You can implement your own functions at will, but in front of Drupal, things become different, which may make developers feel like they have found a treasure. Here, we need to briefly introduce the system architecture of Drupal. The entire Drupal system is built in layers. of:

The bottom layer:

is the framework layer, based on the popular Symfony framework. Symfony can be said to be the industry standard for PHP and the most famous framework in the world. Another famous PHP framework is Laravel itself. Many parts are also based on or come from Symfony. Developers who know the Symfony framework can quickly start developing Drupal. Fabian, the author of the Symfony framework, is a legendary figure. Another of his well-known works is the Twig template engine, which also uses Among Drupal, Drupal is the most famous example of Symfony. Its official website lists Drupal first, and the Drupal community also participates in Symfony code contributions.

The second layer:

is the data layer, represented by entities, which provides various data upwards. Database encapsulation belongs to this layer. The ORM concept and the model concept in ThinkPHP are similar to the entity concept. How it looked in the very early days

The third layer:

Application layer, developers handle various business logics at this layer

Here developers need to pay attention to When using Drupal, you don’t have to call it layer by layer, but you can skip it and go directly to a certain layer. Therefore, when developing directly for the framework layer, you can use the entire system as a framework, just like ThinkPHP development. It’s the same as using the ThinkPHP framework directly, which is why Drupal can do everything ThinkPHP can do. The difference is that Drupal uses the Symfony framework. As an aside, ThinkPHP is deeply influenced by Symfony, and even directly adopts some of its components. In many aspects, it is highly Drawing on the Symfony framework (any creator is worthy of respect, so the word "plagiarism" is not used, but "borrowing" is used). The main process is almost the same, but there is a huge difference in maturity and details. This gap is as follows: Image description:

When human ancestors were counting with knotted ropes, a fruit was a fruit and a fish was a fish. When the number "1" behind them was abstracted from each specific thing, Humanity has faced a huge leap. The significance of this moment is no less than the use of fire, and the invention of numbers, mathematics, etc. In terms of time and space, human beings have been constantly exploring and abstracting the world, and have accumulated talents countless times. With today's civilization, it can be said that the higher the level of abstraction, the stronger the meaning and the more direct it is to the essence.

Many great works require huge manpower and time to accumulate, so how big is the accumulation gap between ThinkPHP and Symfony, or between ThinkPHP and Drupal? What I can tell you directly and decisively here is that there is a gap between elementary school and college, with junior high school and high school in between. The main reason is the community size, ecology and time. ThinkPHP and Symfony are both frameworks and are the most direct competitors. To exist, ThinkPHP needs a path of independent innovation, but it borrows a lot from Symfony. This is a very embarrassing thing. As a developer, why not use it directly? What about Symfony? The CI framework (CodeIgniter) at the same level has developed completely independently. You can't see the shadow of ThinkPHP in many global rankings. However, in China, you can see the shadow of ThinkPHP in many recruitment information. This is a very strange phenomenon. Because ThinkPHP is a completely local product, even the annotation documents are in Chinese. It is based on this that this article chooses ThinkPHP as the starting point for studying the status of Chinese and foreign software.

What is a good system? What do we need?

As the saying goes, if you want to do your job well, you must first sharpen your tools. Here are a few points to illustrate what characteristics an excellent system should have. Below we will use these to compare ThinkPHP and Drupal:

Completeness:

You can think of the so-called completeness as a tool or component that has been designed with all situations fully considered. For example, the string interception function provided by PHP natively will truncate UTF-8 characters and produce garbled characters, and you designed An interception function not only does not do this, but also does not truncate English words. It also takes into account not to truncate tags in HTML. Then your tool is more complete than the PHP native function. Once you find that there are columns that cannot be satisfied, you need to improve it. Improve completeness. The design of many parts of Drupal is "complete". Although Drupal continues to explore and evolve, this level of completeness far exceeds ThinkPHP. For example, Drupal's routing system can naturally support based on domain name, protocol, HTTP Methods, data formats, options, etc. are routed. If they all match, there is priority classification. These are not fully available in ThinkPHP. The completeness of this component design relies on the depth of understanding of the nature of the transaction and a large amount of development experience. , completeness allows mankind to continue to move forward based on the predecessors.

Standardization:

Standardization is the prerequisite for large-scale collaboration. System hierarchical structure, cross-system communication, decoupled components, etc. are all inseparable from standardization. Drupal is completely oriented to RFC documents are not self-contained systems. References to RFCs are often seen in comments or discussions. RFC documents are the cornerstone of the IT Internet. They are similar to national standards common on products. They are often ignored by users, but they are extremely important.

Integrity:

Cooperative division of labor. When the developed and complete components are put together and everyone uses them, this constitutes completeness, and then People do not have to reinvent the wheel themselves and break through involution. Integrity will in turn promote the improvement of completeness. Symfony and Drupal solve the integrity problem in the form of components and modules.

Low coupling:

Each component of the system design needs to be decoupled as much as possible, so as to give each component more room for development and improvement. Bad Components are also easy to replace. Drupal adopts a modular design, and even the core is modular. Users can replace any core file in the user space without directly modifying it to avoid insufficient functions and hindering upgrades. Relatively speaking, ThinkPHP is tightly coupled.

Master the boundaries:

A good system must be a system with proper control, but this is really a bit difficult, and benevolent people have different views on benevolence and wise people have different opinions. Generally speaking, The general direction or backbone system must be concise. Here is an example. ThinkPHP supports determining routing controllers based on routing parameters, that is: Route::get(':action/blog/:id', 'Blog/:action' );, and Drupal does not allow this. When implementing similar functions, proxy controllers are usually used. In short, this effect should not be implemented at the routing level, but should be implemented at the controller level, which makes the routing system more concise. The system architecture is clearer. This idea runs through Drupal, making the backbone of the Drupal system very simple and clean. When you want a detailed function, first enter the corresponding large tributary and then enter different detailed tributaries. Is it like a tree? ? But which way do you prefer?

Simplicity:

To be simple, the system needs clear processes, unified calls, consistent rules, no extras are allowed, or extras should be avoided as much as possible. The advantage of this is It is easy for newcomers to learn, and it is very convenient to track and troubleshoot.

Vitality:

The vitality of the system also lies in sustainability. The ecosystem and developers are the nourishment of the system, which will be discussed below, but will be skipped here.

Comparison between ThinkPHP and Drupal:

Comparing ThinkPHP with Drupal, in general, ThinkPHP has insufficient abstraction and insufficient accumulation. This is The fundamental shortcoming is that it is like a child. Drupal is an adult who has experienced years. He knows more, knows the general principles behind things, and has gone further. Suppose we are building a building, and ThinkPHP provides concrete. , bricks, steel bars and other basic building materials, developers need to explore how to build, how to design and other architectural issues. Drupal not only provides basic materials, but also comes with a construction team and design institute. Many times you only need to say You just need to build a building with whatever feel and function you want (the needs you meet have usually been met by others, forming a large number of contribution modules, which can be installed). Of course, if you are interested, you can also participate in the construction. The process gets you customized results.

This chapter compares the two at the level of technical architecture. If you are not a developer, or are not interested in specific technologies, you can skip this chapter directly and continue to the next chapter. Here, the latest versions of ThinkPHP are used. 6.0.7 and Drupal 9.1.7, due to limited space, only some important contents are selected for comparison:

Events:

In ThinkPHP, events are positioned to replace the original behavior and Hook mechanism. It can be seen that the author does not realize the essential difference between events and hooks. The same point is that third-party code is used to intervene in the current logic processing. But under this general premise, hooks focus on participation, and events focus on notifications. They are very different in quantity and nature. ThinkPHP confuses them, while Drupal understands them more essentially. Due to ThinkPHP's lack of understanding of the concept of "events", it also leads to The implementation is loose and complex, and there are major functional deficiencies. For example, ThinkPHP events have no concept of priority, which is crucial when there are order requirements. At the same time, there is no event propagation termination mechanism. For example, ThinkPHP does not require the implementation of event classes. In fact, to process events, parameters usually need to be passed, and the processing results need to be fed back to the source of the event, so the event class is necessary. ThinkPHP is very basic, and Drupal uses the event dispatcher service to process all events, and subscription There are no special restrictions on processors and listeners. To process event-related logic anywhere in the system, you only need to face the event dispatcher service

Middleware:

In Both ThinkPHP and Drupal have the concept of "middleware", but their positioning is very different. In ThinkPHP, the functions implemented by middleware are handled by the event dispatcher in Drupal. For example, the ThinkPHP document mentions that middleware is mainly used For intercepting or filtering application HTTP requests, this is what dispatching request events does in Drupal. In addition, routing middleware and controller middleware are also the same. They correspond to routing events and controller events, and the middleware in Drupal The main function of the software is to change the HTTP processing core from one to multiple. In terms of logical architecture, Drupal is much more elegant and clearer than ThinkPHP. This is also caused by ThinkPHP's insufficient understanding of the event mechanism, which makes the system structure cluttered and provides a better environment for future upgrades. The burden is buried

Entry file:

The entry files of both are very simple, and the logic is relatively similar. There are three main differences:

1. Drupal directly injects the request object into the processing core in the entry file, which literally reflects the concept of "any web system is a system that converts requests into responses." Although the run method of ThinkPHP's HTTP service can also be used, But it is not reflected at the entrance, but there is no essential difference. The big difference is that ThinkPHP lacks support for the "sub-request" function, that is, the ability to submit requests to itself for processing while the system is running. There is no need to jump out of the system and come back. , this function has a great impact on the system architecture (throughout the entire system, sub-requests must not only affect the environment status of the main request, but also consider performance). This point best shows that Drupal's system architecture is much more powerful and complete than ThinkPHP Much higher, Drupal can better handle complex business logic

2. True simplicity, Drupal has only one entry file globally, whether it is multiple applications or single application front and backend, etc., there is only one Although users can set multiple entries, multiple entries are not recommended. This reduces complexity, keeps it simple, and lays the foundation for the URL alias system. ThinkPHP has a complex multi-entry mechanism, especially when using multiple applications. This is also useful for URL alias support will be more difficult

3. Drupal passes the class loader to the processing core in the initial state, which naturally supports replacing or modifying the class loader, but ThinkPHP does not support it, it just loads it. , when the class loader needs to be modified, it cannot be obtained, which greatly reduces flexibility. For example, many classes cannot be replaced with the user's own. For example, it is troublesome if you want to replace the "\think\Http" class.

Multiple applications:

Both support multiple applications, that is, multiple systems reuse the same set of code, but Drupal is much simpler in terms of specific methods

Interface-oriented programming:

In many implementations of ThinkPHP, interfaces are not extracted from classes, and even some important classes do not have interfaces, such as:

\ think\App

\think\Request

They are so core and important, but they do not have their own independent interfaces. ThinkPHP is not programmed strictly according to the interface, which greatly reduces the flexibility, such as I want to implement my own app class to replace \think\App, but I can't do it. I can only modify the core, so upgrading every time is a problem. In Drupal, it strictly follows the interface, and the architecture is completely oriented to the interface and parameter types. The constraints are all interfaces. We can replace any class provided by the core without modifying the core, including the most important HTTP core class: DrupalKernel, which is similar to the ThinkPHP app class.

In addition to affecting scalability, not strictly following interface programming also has many other disadvantages, such as being unfriendly to IDEs, difficult to automate document extraction, no inheritance of code comments, inconvenient collaborative discussions, etc.

Routing system:

Quoting the original text of ThinkPHP official tutorial:

"ThinkPHP is not forced to use routing. If no routing is defined, you can directly use "Controller/ Operation "Access"

It can be seen that the framework author has insufficient understanding of the essence of routing. As mentioned above, the number 1 has not been abstracted. The so-called "controller/operation" method should also belong to the default route or The seemingly innocuous point of internal path routing, rather than no routing, is actually very important and involves essential cognition, which leads to very different behavior.

Routing is a fork in the road after entering the system and must exist. Many business logics need to be processed here, such as permission control, parameter conversion, path alias processing, language processing, etc. In ThinkPHP, there is no need for routing. In addition, such cognitive results will inevitably make things loose and complicated, such as code redundancy, inconsistent use, etc.

Entry processing is only one of the two major functions of routing. The other major function is exit processing, which is the generation of system-wide URLs. This is crucial for URL alias processing, language negotiation, SEO, etc., but There is only a simple implementation in ThinkPHP, and the responsibility of the routing system has not been fully realized. For example, here is a requirement:

The user adds "target="_blank"" to the URL of the entire system in a custom function How to achieve it?

Containers and Dependency Injection:

This concept and name originated from the Symfony framework, for details, see:

https://symfony.com/ doc/current/components/dependency_injection.html

In short, the main idea is to set up a central large object in the system, which can also be called a parent object, which is responsible for collecting, saving, and automatically instantiating our commonly used objects. Object. In Symfony, this large object is called a container, and the object saved in it is called a service. The definition of the service can be provided statically in YAML or dynamically through a service provider. The "definition" has a certain format. When we need a service The container object will instantiate the service object according to the definition, and then save and return it. The definition involves concepts such as classes, parameters, factory methods, post-instantiation callbacks, configurators, public and private properties, feature inheritance, delayed instantiation, etc. The container Before formation, there will be a service compilation process to handle advanced functions such as service groups and parameter modifications. Each service in the container has an ID, called the service ID. The service object is obtained through this ID at the place of use. In the container In addition to saving services, container parameters, service aliases, etc. are also saved.

ThinkPHP's container concept has the shadow of Symfony, but it is still very young and elementary. Its implementation is far from simplicity and is confusing. For example, there is no clear concept of service ID, and the service object in the Symfony container , there must be a corresponding service ID, and ThinkPHP calls a similar concept abstract, which can be an identifier or a class name, but some container methods use it as a class name, such as:

\think\ App::register

\think\App::getService

It seems that the author wants to be as flexible as possible, but it leads to confusion caused by inconsistency. The concept of "service" in ThinkPHP There is a separate definition (a bit like the service of the operating system), but it is essentially a Symfony service, but with special processing. In Symfony, putting the service into the container is called "collecting" the service, or "injecting" it into the container. , and ThinkPHP calls it "binding" the service to the container. As the name suggests, the container is used to hold things. Why is it called binding? This kind of name is very difficult to pronounce, and there are many names that do not convey the meaning. For example, ThinkPHP calls the post-instantiation operation of the object in the running container a "post-execution" operation, not a "post-instantiation" operation. There is a saying in the computer industry Famous saying: "What is difficult? Caching and naming." ThinkPHP needs to be improved in this area. Some of the current naming is not friendly to novices.

In addition, services (in ThinkPHP should be called classes, objects or callbacks bound to the container) can also bind services to the container. This feature seems flexible, but it is very inconvenient for code tracking and debugging. Friendly, it makes it more difficult for newcomers to take over the system. Drupal benefits from its modular design, which allows centralized declaration (because the module must know which services the service depends on, and the container compilation mechanism can also determine whether a service exists), so that in Tracking the code and debugging is made as simple as possible, and it is also convenient to export the service definitions in the runtime container without actually instantiating each service.

Façade:

This is just a concept in ThinkPHP, used to statically call the dynamic method of the packaged class, that is, use the static method to proxy the class to the method level , this is just a formal adjustment, and the object still needs to be instantiated internally. In fact, this concept is not necessary. It is not only very unfriendly to the IDE but also violates the original intention of PHP static method design. It only makes up for the lack of container functions in ThinkPHP. There is no such concept in Drupal. Its functional purpose is to uniformly use the \Drupal::service($id) static method to obtain service instances, and then the developer can call its dynamic method by itself. If a different instance is needed, it can be cloned by itself, which also avoids the use of The trouble with introducing proxy classes.

Assistant function

There is a concept of assistant function in ThinkPHP. The document mentions that its purpose is to enjoy the convenience of automatic reminders from the IDE, which is equivalent to "\ "Drupal" global class provides static methods or shortcut functions, but Drupal is not because of the IDE, but because it is more convenient to obtain services, because PHP functions or static class methods are super-globally available.

Controllers and Models:

In ThinkPHP, it is believed that the controller is used to do pre-business processing logic. It must be a PHP class or closure. The business logic is a matter of "patterner". In fact, this is a very rigid and dogmatic point. First of all, the controller It can be a PHP callback expressed in any form, including functions, container instance methods (defined with container IDs), etc. Secondly, in reality, the boundaries of business logic are not so clear, and it is difficult to abstract the "pattern" and then give this The name, again, the controller should already be the beginning of business processing, and what the controller in the ThinkPHP concept does should be processed in routing. ThinkPHP has already realized this and mentioned it in the document.

Multi-language processing:

In terms of implementation, ThinkPHP and Drupal are both based on English as the development meta-language. ThinkPHP’s translation implementation is very simple and often cannot be satisfied in reality. needs, especially when developing international applications (this should be caused by insufficient application coverage), Drupal has a complete multi-language system, which has completely dealt with the following concepts:

Language singular and plural issues (some languages ​​are more than Singular and plural) contextual issues (is "may" translated as "can" or "May"?) The translation interface, configuration and content language of the text in JS, the translation collaboration mechanism of the left text language, etc.

ThinkPHP does not have these, it only simply implements the translation of text in the template and the replacement of variables in statements; in addition, Drupal naturally has multiple language negotiation mechanisms, such as user settings, URL prefix, session information, domain name, HTTP header, user agent identifier, etc., and supports customizing the language negotiation mechanism through plug-ins. By default, ThinkPHP only supports URL, HTTP header variables, cookies, and browsers. Note that if you use cookies to transfer language information, it may be possible when developing international systems. Legal issues will be encountered. Many countries require the system to explicitly ask users whether they can use their cookies. In summary, when using ThinkPHP, developers need to solve most language problems by themselves. However, in fact, the multi-language system runs through the entire system, which is very large and complex. Drupal due to It is an internationally co-built system. Multi-language is one of its highlights. It is a natural multi-language system. This alone may stump ThinkPHP developers.

Cache system:

A complete cache system has three elements: expiration time, expiration tag, and context. Drupal has a complete implementation of it, while ThinkPHP only implements time and Tags do not implement context, so what is context? Simply put, it indicates who the cached object belongs to and under what environmental conditions under the same cache key KEY. For example, the user's permissions, login status, language, IP, protocol version, topic information, etc. all belong to the cache context. The same KEY needs to read different cache objects under different context conditions, which is crucial for large-scale system design, and the system is very large. ThinkPHP requires developers to solve the cache context problem by themselves. In addition, ThinkPHP does not provide a cache merging mechanism. This will not enable hierarchical cache processing, which is essential to achieve efficient caching.

Session:

Developers using ThinkPHP have to solve session-related issues themselves. Why? With the development of IT today, only small and micro systems use only one server, and most systems will load balance to multiple servers. Therefore, applications must require statelessness, so session data cannot be stored locally. The usual solution is to store Based on this, because ThinkPHP is a framework that cannot provide an existing solution for database storage of sessions, developers need to handle it themselves. Drupal itself has taken into account things such as load balancing and application statelessness, and sessions have been stored in the database by default. It can be used out of the box. Although ThinkPHP provides expansion capabilities, developers still have to pay a lot of labor costs to implement development

There is a problem in ThinkPHP's session implementation: the session is not saved after the script ends, but It is executed in the script, so that when the user calls die or exit, it will not be saved. The shutdown function should be registered. For details, see the php function:

register_shutdown_function

Database:

Both ThinkPHP and Drupal support multiple databases. ThinkPHP created a concept of "distributed database" to describe this feature. Drupal has no special rendering concept and only uses business identifiers to distinguish different databases. , both also support master-slave configuration and read-write separation; but in terms of implementation, it is obvious that Drupal is much more elegant. For example, in the data structure of database configuration, Drupal uses a multi-dimensional array. The first-level key name is the business identifier, and the second-level key name is the business identifier. The level key name is the master-slave identification, and its value is the connection configuration information. This structure is very simple. If you want to implement a database load scheduling subsystem, then the interface of this structure is very simple, and in ThinkPHP's configuration data structure, Store all host addresses under one array key, store all passwords under another array key, and so on, as well as user names, etc. Such a structure requires parsing the configuration information again when generating connection information. Not only Reading and modifying is not intuitive and consumes system performance. The interface of the database load scheduling subsystem is also complex and very inelegant.

Both also support multiple types of databases. The core of Drupal comes with support for three databases: mysql, pgsql, and sqlite. In addition, the community module has almost complete support for all commonly used databases. At the bottom, Drupal combines different databases The difference is called "dialect". The processing of different dialects is completed in the driver layer, providing a unified interface to the upper layer. In other words, the upper-layer database operation class cannot sense what database is used at the bottom layer, and adopts standard SQL specifications, which is perfectly shielded. The difference is that database decoupling is achieved, and module developers do not need to consider which database the user is using. Table creation, query, modification, etc. are all unified. When switching between different types of databases at the application layer, it can be done with one click.

Regarding database operations, since Drupal is a complete system, it has implemented a set of very advanced data storage structures by default. This structure provides support for the system data layer. When everyone is based on a unified data structure , a wonderful thing happened. People distributed around the world can cooperate to implement rich upper-level applications. This structure created the famous entity concept. As a result, Drupal also provides more operations on data, such as entity query, and users implement Out of the box, Drupal is inclusive and users can define their own data structures.

ThinkPHP cannot support the data layer. ThinkPHP uses models to handle data encapsulation and operations. Compared with entities, models are very early and young concepts. All entities it can do can be used. , but not vice versa. For example, the model does not support field controls for input, formatters for output, display controls for forms and views, etc. The reason is that these require higher-level implementation.

Chinese and foreign open source ecology and connections:

After full comparison, you will understand that Drupal can do what ThinkPHP can do, and do it better Well, the other way around doesn't work, because Drupal is a complete back-end system, known as the WEB operating system. It has helped do more things. Common needs are basically all available, and it can be used out of the box. ThinkPHP developers want to To get those functions, you need to go a long way based on ThinkPHP. Putting aside the quality issues, the time consumption alone is an astonishing number (for example, before the official version of Drupal 8 was released, its various development versions were composed of a thousand Many top international developers have been working on this for five years). In fact, many Drupal developers do not bother to learn ThinkPHP or other frameworks. However, a very strange phenomenon can be found in China: Why are there still many small companies in China? Using ThinkPHP? (You can get a little idea of ​​this by searching for PHP recruitment information on various recruitment platforms). There are two reasons to explain this:

Cultural exchanges are blocked:

The exchange of culture and life between China and foreign countries is still limited to a small number of people. Most people have no friends from foreign countries. The main reasons are the well-known network barriers and language problems. The language barrier should be the main reason. Our country is developing too fast. At present, the main force of domestic developers is the group of people born in the 70s to the 90s. Most of them have poor English communication skills, are mute in English, or have difficulty reading. They often instinctively do not access English materials. Those born after 00 or 10 The English level is much higher (thanks to early professors, the Internet, etc.). In the future, they will be more integrated into the international environment. Fortunately, technology is now developed, the level of translation software is getting higher and higher, and more and more people are devoted to technology. Introducing the above, for example, Drupal in China has a large number of technology platforms such as "Drupal China", "Aima Document Collection", "Shui Drop Room", "Drupal University", "Think in Drupal", "Ninghao.com", etc. These platforms or blogs provide huge and almost complete Chinese documents, eliminating language barriers. There are development companies with Drupal as the core technology in cities such as Beijing, Shanghai, Guangzhou, Chengdu, Nanning, and Ningbo.

Fast food phenomenon caused by stress:

The Chinese are definitely one of the most hard-working people in the world. This hard-working is largely related to pressure. Housing, marriage, medical care, education, and elderly care are each a big mountain. "Making money" must be the top priority. Important matters, for most ordinary people, maintaining ingenuity and long-term accumulation is too risky, and there is a lack of security. The money that can be made now should be made first. Who knows what will happen in the future when society develops so fast? This phenomenon has a negative impact on The damage to the basic science field in our country is huge, and the same is true in the rapidly developing IT industry. The burden on our developers is too heavy. 996 is even respected by large companies. They have been doing simple code farmer work like CURD for a long time. Many developers I don't have much time to study at all. I have to spend some time with my family, children, and girlfriends. I have very little time to rest, so it's even harder to study in depth. If I have extra time, I usually use it to take on private work and make extra money. In such a general environment, everyone is accustomed to "eating fast food". If they have a hoe, they use it first. They have no time to learn excavators. It is even more expensive to develop excavators. In the end, it makes it difficult for my country's open source industry to develop. The few Open source projects have a strong commercial flavor. Small companies rely on advertising subsidies and open source projects to attract commercial projects to make money (you can feel it by looking at the homepage of ThinkPHP), while large companies use it to cultivate reserve talents, eliminate bugs for free, etc. The choice of open source has a strong "sphere of influence" color. In general, pure love and interest account for a small proportion, but this should not be blamed on Chinese developers. This is due to the heavy pressure environment. Now There is also a phenomenon of escaping from first-tier cities. Many people go to second-tier cities that are less busy and have some free time. Maybe they are a force for open source. Get APP (Luoji Thinking) also predicts that China’s innovation center may move to Those second-tier cities with leisure.

On the contrary, the soil for international open source is much better, and it is dominated by many developed countries, and these countries are usually welfare countries. Compared with the pressure, there is not much room for people to do things based on their interests. Many people participate in open source. The primary consideration is the meaning of life. There is a "Maslow Needs Model" about this. Readers can learn about it. "Like" guarantees "quality", and benefits allow developers to ignore age and work. At the annual DrupalCon conference On the Internet, you can see that many developers are very old, many in their 50s and 60s. They talk about technology with bright eyes and inject a lifetime of accumulation into Drupal.

Of course, international open source is not mainly participated by developed countries. English-speaking underdeveloped countries are also key participants. They often earn foreign exchange through commercial projects derived from open source. A typical country is India, which is polarized. Seriously, it was once colonized by the British, and the popularity of English among its high-end people is very high. This has made India highly integrated into international open source, and accordingly created India's relatively high software development strength.

Developer career planning:

This section discusses the career planning issues of domestic developers. There has always been a voice in domestic society: "Programmers eat youth food", which usually corresponds to the 35-year-old threshold. You may often see a certain large company dismissing 35-year-old developers. Some companies have a recruitment age limit of no more than 35 years old. It is strange that 35 years old It is the age when you have accumulated deeper abilities and can handle many things appropriately. Why does this phenomenon occur? Let's explore:

First of all, those news are highly suspected of attracting attention, just like "female drivers". In fact, the accident rate of female drivers is less than that of male drivers. It is precisely because they are less that they are Only news can make you browse, but if there is too much news like this, you will form an illusion. Therefore, the 35-year-old threshold has been over-exaggerated to a certain extent, causing a bad impact, and some people even follow the trend without reason.

But there is some truth to the 35-year-old threshold. This needs to be selectively distinguished. If a developer has been doing simple and repetitive physical work like CURD (a real coder), then when he reaches the age of 35, Compared with young people who have just been out of school for a year or two, the competitiveness can be imagined. At the age of 35, there will be great pressure on children to go to school, parents' health, housing, etc., forcing developers to put forward higher salary requirements, family affairs, socializing, etc. You also have to wait a lot and don’t want to work overtime. Usually, the accumulated salary for a longer period of service is relatively higher. If young people can do what you do, who will the boss choose? At the same time, getting older has some face issues. If your boss is a young man who is much younger than you, should you obey him? It can sometimes be awkward for young people to manage someone much older than them. Based on these, it can be seen that the existence of the 35-year-old threshold has a certain reason.

Time waits for no one, so how can developers avoid the 35-year-old threshold and how should they plan their lives?

If you find that you don’t really like technology, then you should transform as early as possible while you are still competitive at your age, follow your heart, find something you like and start to accumulate competitiveness.

If you really like technology and are willing and ready to spend your life doing it, then you need to accumulate efficiently, keep learning, and always pay attention to widening the technical gap with young people, who have less pressure and physical strength If you have a strong advantage, you need to make up for it with technical advantages. The road to becoming a great master is not something you can choose or not, but a must. When you reach the age of 35, you must be a great master and take on system positions that are difficult for young people to do.

I need to remind you that with the development of society, the threshold of technology is actually gradually increasing. For example, you may have heard of "full stack engineer", but that only belongs to the early days of the Internet era. Nowadays, the division of labor in society is too great. If the details are too deep, the whole stack no longer exists. If it does exist, it can be called "knowing everything, but there are differences in skills", because the gap in people's energy will not be too big. You choose to study them all, while others choose to study one area. Employers hire people based on their positions. You need to consider who has the advantage. Reason will make you choose to delve into one subject deeply and understand the surrounding areas. But in this way, you will become a component in a big machine and your freedom of choice will be restricted. , the subdivision threshold requirements will be very sophisticated, and you will only have a superficial taste. If you don’t seek proficiency, you will face elimination.

Making such machine parts is not suitable for people with entrepreneurial aspirations, so what will they face when starting a business? Looking at the development of Chinese society, you may not have a chance to meet all common IT needs. For example, websites are replaced by public accounts, and the small website market is also occupied by SaaS platforms. To compete with such platforms, they only need to click the mouse to initialize. , you have to write code, and their time-based charges can be very low. You have to charge a one-time fee. From the customer's perspective, the first consideration is of course the cost issue. General requirements also include e-commerce systems, live broadcast systems, content payment systems, etc., and These all have very mature existing solutions. In terms of scale advantages, Weimeng, Youzan, Weiqing, Weijianmu, etc. are all very good SaaS platforms that have been developed. What about non-general IT needs? Solutions in many vertical fields will be formed, and the top of the mountain will be seized and divided, such as Meituan, Didi, Tubatu, Dingguagua, etc. It is difficult for you to have a chance in their fields, leaving only the number of developers. There are not many demands that really require customization. This kind of demand has one characteristic. Because it is customization, cost reasons determine that the unit price must be high. At this time, customers will have requirements for the strength of the entrepreneur's company. How many employees do you have? How big is the office? How long is the historical accumulation? How many cases are there? How high is the registered capital?

In addition, with the development of IT today, the same application system will take on many forms in terms of software. It usually requires one or more of Apps, small programs, web pages, etc., and also involves cross-platform (APP There are Android, IOS and the upcoming Hongmeng, and mini programs involve WeChat, Alipay, Baidu, Douyin, etc.). Although there are tools like UNIAPP, many skills are still required when customers require native applications, which leads to the need to set up Team members also include non-technical personnel, such as salesmen, finance, etc., which form certain barriers to entry. In the end, you will find that starting a business requires more than just technology, but also capital.

Having said this, do you feel that the road is difficult? But please believe that this is not the case only in the IT field, but also in places with competition. No success is easy. Only your interest can guarantee how far and high you can go, so please follow your heart.

If you follow your heart, and after careful consideration, you still choose to do technology and become a great master, then what should you do? First of all, you must focus on accumulation, especially standing on the shoulders of giants and rushing towards undeveloped land. You need to find the most promising ecosystem in your niche, join it, and return to the PHP development framework, Xiaobai Looking at the framework, it only further encapsulates and provides the required functions, but the expert sees that the framework provides a unified collaboration platform. Everyone creates on the same platform, so as to avoid reinventing the wheel, which is sufficient in terms of economic cost. It's cost-effective, and with the help of everyone's strength, you can free up your hands to develop your own business.

The unity of the basic platform is very important. Only in this way can humans accumulate and move forward and reduce costs. However, there is an interesting rule in the formation of a unified platform, that is, in the end, only one will be left as the main platform, and then there will be another The second place platform is used to form a competitive reserve, and the third and fourth place platforms can basically be ignored, and the first and second places will be very different in terms of size. There are many such examples, such as in history. There are thousands of operating systems, and ultimately only window and Linux are left. There is a huge difference in the number of users between the two. The same is true for Android and Apple, Taobao and JD.com, Douyin and Kuaishou, Meituan and Ele.me, etc. Once Once a pattern is formed, it is difficult to shake it. For example, Microsoft cannot shake Android, not because of technology, but because the snowball effect is at work. The king will be stronger and bigger, and the loser will gradually become lonely and disappear, even if the king makes some small mistakes and develops It cannot be changed. For example, the keyboard we use now does not have the most reasonable letter arrangement. There have been keyboards with reasonable arrangements in history, but because everyone is accustomed to the current keyboard, they continue to use it. To become There are two important points for the king: the technological advancement must be sufficient, and the community ecology must establish a snowball effect. These two points complement each other.

So who will become this unified basic platform in the field of PHP framework? The main development force of an open source project should be that a large number of users continue to refine and summarize it during use, and then continue to discuss and improve it together, rather than a few people relying on their own thinking or experience, so if in ThinkPHP and Symfony Make a choice, the answer is very clear. In fact, Symfony has realized the significance of a unified platform very early, so it has devoted itself to the establishment of decoupled and complete basic components, and iterated repeatedly, so that some other existing frameworks also use Symfony components. , such as Laravel and ThinkPHP, Symfony has repeatedly emphasized "standards" and has now become a de facto standard in the field of PHP development, because standardization is a necessary condition for a unified platform.

As for Drupal, it is a higher-level unified standard platform built on the basis of Symfony, which has become the standard basis of the complete system. Almost all commonly used application layer functions here have been provided, and people are working on it. On a unified platform, based on modular design, more future-oriented functions are created to realize Drupal's ideal of "providing excellent digital experiences."

Decision maker technology selection:

If you are an entrepreneurial boss or project director who is making technology selection for a project, So here are a few things to note for you:

Control costs:

This seems to go without saying and is a matter of course, but have you really controlled it? Software is intangible. If you are not a professional, it is difficult to control costs. Here are some pitfalls:

In the current environment, if you want to do a long-term planning project and can develop it yourself, don’t outsource some things. Although they look the same, there is actually a huge gap. It is difficult for unprofessional people to see the differences between the two systems in terms of robustness, scalability, security, sustainability, etc. For example, a system with the same function has a load of 5,000 and a load of 5,000. The development cost of tens of millions is completely different. For example, the workload of software documentation is sometimes much higher than the software development itself. Documentation is the key to ensuring the long-term development of the system, but it is difficult to achieve complete documentation in outsourcing. The quality of outsourcing usually makes you inefficient. The reason for paying the bill in the future is not because the outsourcing company is not strong, but because of the cost.

Less technical debt:

Don’t find developers who don’t have enough experience just to save money at the beginning. Let me share a story here: There is a boss and a technical director who There were differences in talent recruitment. The technical director asked for a job salary of 15,000. An applicant came and only wanted 8,000. The technical director didn't want it, but the boss was overjoyed and thought he had made a profit. Why should he stupidly pay more? Sometimes novices will leave huge hidden dangers in the system. This technical director has seen the problem of technical debt. The development team must have a deep technical backbone to control the system. At the same time, when choosing a basic system, do not choose one with low maturity. This way, you can ensure that you owe no technical debt as much as possible, otherwise you will start to get used to the road and get stuck in the quagmire later. If you encounter a critical business window period, even the gods can’t save you

Leverage to accelerate:

With the development of society today, many IT system functions already exist and are very complete. You don’t need to develop them yourself. For example, if you have to choose between ThinkPHP and Drupal, I will not hesitate. Choose Drupal because ThinkPHP is just a semi-finished product, and some functions are usually necessary in various business systems, such as garbage collection system, status system, key-value storage, batch processing system, scheduled task system, data typing system, Ajax system, Data viewing engine, version support system, permission system, etc. are not available in ThinkPHP, but Drupal is very complete. It will take months to years to develop these on ThinkPHP. Not only does it not have the advantages of a basic unified platform, It is also difficult to ensure the quality of the code developed by oneself. Not only is resources wasted, but new members will also need to pay high training fees in the later stage. Why not use a ready-made, mature system with a complete foundation?

Integrate into the environment:

The development system must be integrated into the general environment. In addition to leveraging acceleration, it also depends on the acquisition of reserve talents to decouple developers from projects. Don't be unable to find enough developers when existing developers leave or are insufficient. Quickly join the project, integrate into the larger environment, and decouple developers to a large extent ensure the development security of the project.

National open source recommendations:

#In this section we stand at the national level to see how open source should be treated. Our country is becoming stronger and stronger. Chinese people are looking forward to the day when China will surpass the United States. If China wants to break through the US blockade and achieve the goal of surpassing, it must participate in international open source and become the main contributor, rather than building an independent system of its own (self-built systems should occur in the new era). In terms of things, such as the next-generation Internet of Things operating system Hongmeng), because open source is open source for all mankind, not for any country. It is unwise to work behind closed doors and go out, which will make China stay away from the world. You must know that China only has 1.4 billion people, and There are more than 7 billion people in the world, and ecological power cannot compete with the world. Therefore, the rational approach is to participate in open source and work hard to contribute. First, inherit the existing achievements of human development and develop faster based on the foundation of giants. Second, Then choose to be with the majority of people, open the door to the country, and establish influence. Only then can it be possible to establish the image of a great country.

[Related tutorial recommendations: thinkphp framework]

The above is the detailed content of Drupal compares with thinkphp to see the domestic open source environment. For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:drupalchina. If there is any infringement, please contact admin@php.cn delete