minor【 php框架】2.第一个应用 hello world,minorhello2.1 hello world
2.1.1 配置路由
在app/config/routes.php文件中添加如下配置:
return [ ... '/helloworld' => [ 'name' => 'helloworld', 'controller' => 'app\modules\demo\controller\hellocontroller', 'action' => 'hello' ],];
这样配置之后当我们在浏览器中访问http://xxx.xxx.xxx/helloworld时就会执行app\modules\demo\controller\hellocontroller里的hello方法
2.1.2 创建控制器
在app/modules文件夹下创建文件夹: demo/controller/,然后创建文件hellocontroller.php,然后在文件中写:
'world']); }}
2.1.3 创建视图文件
在app/modules/demo/文件夹下创建文件夹/tpl/hello/然后创建hello.php:
hello
然后在浏览器中访问:http://xxx.xxx.xxx/helloworld就可以看到hello world了
http://www.bkjia.com/phpjc/1133570.htmlwww.bkjia.comtruehttp://www.bkjia.com/phpjc/1133570.htmltecharticleminor【 php框架】2.第一个应用 hello world,minorhello 2.1 hello world 2.1.1 配置路由 在app/config/routes.php文件中添加如下配置: return [ ... '/helloworld'...