天天看點

tp5前背景入口檔案配置

前台檔案入口建立

1.config.php 配置 (application\config.php

//分頁配置
    'paginate'               => [
        'type'      => 'bootstrap',
        'var_page'  => 'page',
        'list_rows' => 15,
    ],
    //  模闆輸出替換
    'view_replace_str' => [
        '_PUBLIC_' => '/tp5/public',
        '_ROOT_' => '/',
    ]
           

2.application\index\ 下建view目錄 Index檔案夾,index.html 視圖檔案

3.application\index\ 下controller目錄 Index檔案夾,index.php 檔案,

<?php
namespace app\index\controller;
 
use think\Controller;  // 
class Index extends Controller  
{
    public function index()
    {
        // return 'ww';
        return $this -> fetch(); //
    }
}
           

二、多入口配置。

127.0.0.1/tp5/public/index.php/index/index/index 通路前台子產品

127.0.0.1/tp5/public/index.php/admin/index/index  也可以通路背景子產品

前背景分離

1.public 下的檔案index.php

// [ 應用入口檔案 ]
 
// 定義應用目錄
define('APP_PATH', __DIR__ . '/../application/');
// 綁定子產品
define("BIND_MODULE",'index');
// 加載架構引導檔案
require __DIR__ . '/../thinkphp/start.php';
           

綁定子產品後隻能找index子產品,即前台子產品  :測試

2.同在public下建立admin.php

// [ 應用入口檔案 ]
 
// 定義應用目錄
define('APP_PATH', __DIR__ . '/../application/');
// 綁定子產品
define("BIND_MODULE",'admin');
// 加載架構引導檔案
require __DIR__ . '/../thinkphp/start.php';
           

測試

127.0.0.1/tp5/public/index.php/admin/index/index 則再無法通路背景子產品

各自配置入口後,前背景子產品通路分離

前台 127.0.0.1/tp5/public/index.php/index/index

背景 127.0.0.1/tp5/public/admin.php/user/list