One: Entry file
The thinkphp framework uses a single entry mode, with a single portal file, typically the index.php file, located in the application root directory. The entry file must be loaded into the framework entry file, which is the entry file for the thinkphp framework. Optional actions include defining system-level constants, defining debug mode or deployment mode, defining a frame path, or a project path.
Two: Automatic generation
In the case of the first access to the portal file, a module home is automatically generated, located in the project directory, usually under the application directory. (The home module is usually the foreground module.) Next time, direct access to the index.php portal file is routed directly to the index method under the Indexcontroller controller under the home module.
Three: Modular design
In the thinkphp framework, the same application is used for the same portal file, and multiple modules can be included in the same application, such as the foreground module (Home), the Background Management module (admin), and so on. You can add new modules by defining constants in the portal file, and you can bind the controller and model classes to the module.
Four: Controller
In thinkphp, methods in the related controller and controller classes can be routed directly through URLs, and the method needs to be public. Generally speaking, the controller is instantiated according to the user request URL, but can also be manually instantiated controller to use.
V: Model
The role of model classes in most cases is to manipulate the data table, if you follow the system specification to name the model class, most of the cases can be automatically corresponding to the data table. A naming convention for a model class is a data table name that drops the table prefix, is named with the Hump method, and the first letter is capitalized, followed by the name of the model layer.
There are many methods of model instantiation, which can be instantiated directly, using the New keyword. You can also instantiate a model class by using the D method or the M method provided by thinkphp. The D method instantiates the model class, and the M method does not instantiate the model class, only the curd operation on the database table. If the class is instantiated using the D method, the corresponding class is not found and the M method is used instead.
Six: Templates
The template is the content of the view layer, which is used to return the content requested by the user, binds the return value to the template, assigns the data directly to the template, and separates the view layer from the business logic.
thinkphp Study Notes