thinkphp5项目创建
文章描述:
创建 composer create-project topthink/think=5.1.x-dev tp5 […]
创建
composer create-project topthink/think=5.1.x-dev tp5
访问
http://localhost/tp5/public/
开启调试
config/app.php
// 开启调试模式
'app_debug' => true,多应用
1、在tp5/public下创建admin入口文件admin.php

// [ 应用入口文件 ]
namespace think;
// 加载基础文件
require __DIR__ . '/../thinkphp/base.php';
// 支持事先使用静态方法设置Request对象和Config对象
// 执行应用并响应
Container::get('app')->bind('admin')->run()->send() ;
2、在application下创建admin/controller/Index.php文件夹
<?php
namespace app\admin\controller;
class Index
{
    public function index()
    {
        echo "admin";
    }
    public function hello($name = 'ThinkPHP5')
    {
        return 'hello,' . $name;
    }
}
访问:localhost/admin.php
控制器
use think\Controller;class Index extends Controllerreturn $this->fetch('hello',['name'=>'thinkphp']);定义DS
根目录
namespace think;
下面新增
if (!defined('DS')) {
    define('DS', DIRECTORY_SEPARATOR);
}
发布时间:2021/12/02 
                
            
发表评论