ThinkPhp5 development practice 1 build the environment to configure the TP5 framework (continuously update the collection attention)

Article directory

foreword

The php framework helps facilitate rapid application development, not only saves time, helps build more stable applications, but also reduces duplication of code. This article uses graphic mode to record and learn the development of thinkphp5. It must be the most detailed and most suitable for novices. This article is suitable for students who have a certain basic knowledge of php and HTML . Because it needs to be suitable for novices, the series of updates will be very slow. If there are errors, please point out that this article only gives a general understanding of tp5

1. Download thinkphp5.0.10 and install the local environment

Thinkphp5.0.10 download
Xiaopi phpStudy download
Download Sublime Text3 (development tools don’t matter)

After the download is complete, unzip the thinkphp5 compressed package to the desktop, as shown in the figure:
Open the downloaded application installation as shown in the figure:
Then change the website directory to the [framework] directory and point to the public folder

2. Download the H-UI backend template

Download H-UI Backend Template

Third, the introduction of static files

Open the tp5\public\static folder and put the downloaded file style into this folder as shown in the figure:

Fourth, create a background page home page

First of all, we first create a new view folder in the tp5 folder tp5\application\index, and then create a new Index folder in the view.
Here is the key point:
the file name Index in the controller corresponds to the class name Index in the file and the index in the view view. Index folder; the method name index of this class corresponds to the view view file (the author did not restore the original state, you only need to look at the framed part, which is not needed for tp5, but tp6 needs to strictly follow the standard) and
then Put H-Ui’s index.html into view/Index as shown in the figure:

Modify the Index.php under the controller controller to:

<?php
namespace app\index\controller;
use think\Controller;
class Index extends Controller
{
    public function index()
    {

        return  $this ->view->fetch(); //View file rendering

    }

}

Next, modify the home page style file, first find the index.html under the view just now
. After the replacement is complete, open phpstudy
and enter localhost in the browser to
see that the page content has been loaded.

Here is a description of the route:
for example http://localhost/index.php/index/Index/index
hostname/entry file/index folder/Index controller/index method****

The above is the basic usage of tp5, the next chapter will carry out the tutorial of logging in and logging out Session

Leave a Comment

Your email address will not be published. Required fields are marked *