PHP development(33)-ThinkPHP5.0(5) namespace and TP5-PhpStorm

黄舟
Release: 2023-03-06 10:42:02
Original
2175 people have browsed it

Based on the first two namespace blog posts, let’s take a look at the relationship between namespaces, public spaces and ThinkPHP5..0:

1 , controller controller

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();
        }
    }
Copy after login

2, view view

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>
Copy after login

Do you still remember our entry file?

\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(&#39;APP_PATH&#39;, __DIR__ . &#39;/../application/&#39;);
// 加载框架引导文件
require __DIR__ . &#39;/../thinkphp/start.php&#39;;
Copy after login
The above is PHP development (33)- ThinkPHP5.0(5) namespace and TP5-PhpStorm content, please pay attention to the PHP Chinese website (www.php.cn) for more related content!



source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!