Minor "PHP framework" 2. First app Hello World,minorhello
2.1 Hello World
2.1.1 Configuring routing
Add the following configuration in the app/config/routes.php file:
return [ ... ' /helloworld ' = ' + [' name ' = ' HelloWorld ', ' controller ' + = ' app\modules\demo\controller\hellocontroller ', ' action ' = ' hello ' ], ];
This configuration then executes the Hello method in the App\modules\demo\controller\hellocontroller when we access the Http://xxx.xxx.xxx/helloworld in the browser
2.1.2 Creating a Controller
Under the App/modules folder, create the folder: demo/controller/, and then create the file hellocontroller.php, and then write in the file:
Phpnamespace App\modules\demo\controller; Use Minor\controller\controller; class extends controller{ publicfunction Hello () {returnView :: Render (' Demo:Hello:hello.php', [' Name' World']); }}
2.1.3 Creating a View File
Create the folder under the App/modules/demo/folder/tpl/hello/and then create the hello.php:
Hello
$name?>
And then access it in the browser: Http://xxx.xxx.xxx/helloworld can see Hello World.
http://www.bkjia.com/PHPjc/1133570.html www.bkjia.com true http://www.bkjia.com/PHPjc/1133570.html techarticle Minor "PHP framework" 2. The first application of the Hello World,minorhello 2.1 Hello World 2.1.1 Configuration route adds the following configuration to the app/config/routes.php file: return [... ' /helloworld ' ...