Based on the first two namespace blog posts, let’s take a look at the relationship between namespaces, public spaces and ThinkPHP5..0:
First we find the index controller (controller),
\application\index\controller\Index.php,
Repair it, the modified Index.php:
<?php namespace app\index\controller; use think\Controller; class Index extends Controller { public function index(){ return $this->fetch(); } }
Then we manually create the following two folders view and index, and create index.html for controlling the index view,
##\application\index\view\index\ index.html,
Created index.html:
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Title</title>iwanghang </head> <body> </body> </html>
\public\index.php, without any modification, let’s run it and the printed result is iwanghang
<?php // +---------------------------------------------------------------------- // | ThinkPHP [ WE CAN DO IT JUST THINK ] // +---------------------------------------------------------------------- // | Copyright (c) 2006-2016 http://www.php.cn/ All rights reserved. // +---------------------------------------------------------------------- // | Licensed ( http://www.php.cn/ ) // +---------------------------------------------------------------------- // | Author: liu21st <liu21st@gmail.com> // +---------------------------------------------------------------------- // [ 应用入口文件 ] // 定义应用目录 define('APP_PATH', __DIR__ . '/../application/'); // 加载框架引导文件 require __DIR__ . '/../thinkphp/start.php';