ThinkPHP5 is an open source PHP language development framework designed to make PHP development simpler and faster. Since the release of the first version, it has gained support and welcome from the majority of developers. Before starting to develop the thinkphp5 project, we need to master the following steps:
composer create-project topthink/think demo --prefer-dist
After the execution is completed, it will be returned on the command line Create project success message. Now enter the project directory and enter the following command to start the project:
php think run
app.php
file in the config
directory under the application directory. This file contains many configuration options for the project. For example, you can configure database link information, URL routing rules, debugging mode, etc. here. route.php
file. You can assign requests to the corresponding business logic controllers and methods by defining a routing array, specifying different request types (GET, POST, PUT, etc.) and request URL rules (supporting the URL definition method of RESTful API). controller
directory of the application directory, and the model can be placed in the model
directory of the application directory. In the controller, we can call the model and operate on the data. What needs to be noted here is that the model needs to inherit the Think\Model class. view
directory by default. You can render template output from a controller by calling a view method within the controller (such as the view()
method). The above are the key steps that need to be mastered to develop a project based on ThinkPHP5. The task left for you is to try to use ThinkPHP 5 to develop a simple second-hand trading platform or blog website!
The above is the detailed content of How to develop projects with thinkphp5 (step analysis). For more information, please follow other related articles on the PHP Chinese website!