2.1 Hello World
2.1.1 Configure routing
Add the following configuration in the app/Config/routes.php file:
<span>return</span><span> [ </span>... '/helloworld' =><span> [ </span>'name' => 'helloworld', 'controller' => 'App\Modules\Demo\Controller\HelloController', 'action' => 'hello'<span> ]</span>,<span>];</span>
After this configuration, when we visit http://xxx in the browser. When xxx.xxx/helloworld, the hello method in AppModulesDemoControllerHelloController will be executed
2.1.2 Create a controller
Create a folder under the app/Modules folder: Demo/Controller/, then create the file HelloController.php, and then in the file Chinese writing:
<?<span>php namespace App\Modules\Demo\Controller; </span><span>use</span><span> Minor\Controller\Controller; </span><span>class</span> HelloController <span>extends</span><span> Controller { </span><span>public</span><span>function</span><span> hello() {</span><span>return</span><span>View<span>::render(<span><span>'Demo:Hello:hello.php<span>', [<span><span>'name<span>' <span>=> <span><span>'World<span>']);</span></span></span><span> } } </span>
2.1.3 Create view file
Create the folder /Tpl/Hello/ under the app/Modules/Demo/ folder and create hello.php:
Hello <?= <span>$name</span>?>
Then in the browser Visit: http://xxx.xxx.xxx/helloworld and you can see Hello World
The above introduces the first application of two steps from hell Minor2 Hello World, including the content of two steps from hell. I hope it will be helpful to friends who are interested in PHP tutorials.