Thinkphp5筆記二:建立模組

來源:互聯網
上載者:User

標籤:font   環境   window   index.php   config   ase   php5   run   php版本   

系統:window 7 64位

Thinkphp版本:5.0.5

環境:wampserver整合

 

我的項目是部署在本地www/thinkphp  目錄下。在做之前,先要考慮清楚,你需要幾個模組來完成你的項目,這點很重要。

 

下面開始實戰:

 

一、建立三個模組 Common(公用模組),Index(前台模組),Admin(後台模組)。公用模組是必不可少的,Index,Admin這兩個模組,其他的你看著辦。

index.php實際配置

<?php// 定義應用目錄define(‘APP_PATH‘, __DIR__ . ‘/Apps/‘);// 網站安裝目錄define(‘SITE_PATH‘,‘/thinkphp‘);// runtime檔案路徑define(‘RUNTIME_PATH‘, __DIR__ . ‘/data/runtime/‘);// 載入架構引導檔案require  ‘./thinkphp/start.php‘;$build = include ‘./build.php‘;// 運行自動產生\think\Build::run($build);

 

build.php配置 (自動組建目錄) 手冊參考:http://www.kancloud.cn/manual/thinkphp5/118021

<?phpreturn [    // 產生應用公用檔案    ‘__file__‘ => [‘common.php‘, ‘config.php‘, ‘database.php‘],    //公用模組目錄    ‘common‘ => [        ‘__file__‘   => [‘common.php‘],        ‘__dir__‘    => [‘controller‘, ‘model‘,‘lang‘],        ‘controller‘ => [‘Index‘],        ‘model‘      => [‘Base‘],    ],    // Index模組    ‘index‘     => [        ‘__file__‘   => [‘common.php‘],        ‘__dir__‘    => [‘behavior‘, ‘controller‘, ‘model‘, ‘view‘,‘lang‘],        ‘controller‘ => [‘Index‘],        ‘model‘      => [‘Test‘],        ‘view‘       => [‘index/index‘],    ],    // Admin 模組    ‘admin‘     => [        ‘__file__‘   => [‘common.php‘],        ‘__dir__‘    => [‘behavior‘, ‘controller‘, ‘model‘, ‘view‘,‘lang‘],        ‘controller‘ => [‘Index‘],        ‘model‘      => [‘Test‘],        ‘view‘       => [‘index/index‘],    ], ];

 

 

1.其中的SITE_PATH,與 RUNTIME_PATH後面都有用到,所有優先放在index.php裡面方便後面調用。

2.這兩個東西,要放一起使用

$build = include ‘./build.php‘;// 運行自動產生\think\Build::run($build);

 

 

 

 

 

 

Common(公用模組),Index(前台模組),Admin(後台模組)

Thinkphp5筆記二:建立模組

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.