Home  >  Article  >  PHP Framework  >  What is the difference between ci framework and thinkphp

What is the difference between ci framework and thinkphp

青灯夜游
青灯夜游Original
2021-12-27 12:02:012678browse

Difference: 1. CI does not force binding templates to operate on the database, but ThinkPHP does; 2. ThinkPHP pays attention to the convenience of use and provides many function assistants, while the use of CI is more cumbersome and lengthy; 3. CI's view files are not configurable, while TP's view files are configurable. 4. TP provides a variety of debugging methods, but CI does not.

What is the difference between ci framework and thinkphp

The operating environment of this tutorial: Windows 7 system, thinkphp v5.1 version, Dell G3 computer.

Compare the functions of ThinkPHP and CI:

  • Model: Template is equivalent to the operation of data. Data There are many forms of storage: such as database, file system, memory, etc. CI does not force binding templates to operate on the database, and ThinkPHP (hereinafter referred to as TP) is strongly related to database operations by default. Indeed, the data operated in practice is generally from the database, but what should we do if we want to operate data of other storage types? In fact, TP only provides many convenient interfaces for operating data. As long as these interfaces are not used, they are still uncoupled; and the storage type driver is configurable, for example, it can be changed to file data operations. So TP is much more convenient.

  • Use of namespace. The CI party does not realize the convenience and elegance brought by namespaces. When CI uses $this->load() to import two models from different modules, there should be conflicts. It should be overridable, but it is inconvenient to use.

  • TP attaches great importance to the convenience of use, so it provides a lot of function assistants. Generally, the normal use is $a=Class::function();, and after using the assistant, it is usually $a = class();, it’s a lot more convenient, just see how you get used to it. CI would be troublesome and tedious to write $this->class->function().

  • Let’s talk about view and template. The storage location of CI's view files is under application/view, and it is not configurable. At least I didn't find a place where it can be configured. TP's view directory is configurable and does not necessarily need to be under the application, providing greater convenience for secure access and view customization and replacement.
    For templates, CI implementation is relatively useless. Although there is a template parsing class $this->load->library('parser'); which can be loaded through the code on the left, it can only realize simple replacement of variables. More complex control structures cannot be implemented, and in the end they have to be implemented with native PHP code (I guess the official also advocates the use of native, after all, native does not require much parsing, is superior in efficiency, and does not need to learn a new set of syntax).
    TP's templates are more comprehensive and mature, and have their own set of syntax. Basically, there is no need to mix in native PHP. Maybe it is a good thing for front-end engineers. They don't need to learn PHP, just learn the template syntax. The division of labor between the front and back ends has become clearer.

  • Now that I think about it, there is a big difference between the MVC directory structure of CI and TP:

    CI's controllers, views, and models each have one directory each, and the module's The division is based on creating new subdirectories under each of the above directories as module directories, or simply creating controllers and models directly in the directories without the concept of modules.

    And TP uses modules as the basic isolation unit. By default, there is a controllers, view, and model directory under the directory corresponding to each template.

  • As for debugging, TP is definitely a few steps ahead of CI. The official method is:

What is the difference between ci framework and thinkphp

CI can only temporarily print out the wrong calls, although this can solve more than 60% of the problems.

[Related tutorial recommendations: thinkphp framework]

The above is the detailed content of What is the difference between ci framework and thinkphp. 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