如何安裝 Luthier CI

安裝 ( Installation )

內容 ( Contents )

  1. 要求 Requirements
  2. 安裝 Installation
    1. 得到Luthier CI Get Luthier CI
    2. 啓用Composer自動加載和掛鉤 Enable Composer autoload and hooks
    3. 將Luthier CI與您的應用程序鏈接 Connect Luthier CI with your application
  3. 初始化 Initialization

要求 ( Requirements )

  • PHP >= 5.6 (Compatible con PHP 7)
  • CodeIgniter 3

安裝 ( Installation )

得到Luthier CI ( Get Luthier CI )

須要Composer
Luthier CI經過Composer安裝。你能夠在這裏獲得它。 here.

轉到該application文件夾並執行如下命令:php

composer require luthier/luthier
複製代碼

啓用Composer autoloadhooks

要使Luthier CI工做,必須在框架中啓用Composer 自動加載和掛鉤。在文件中config.php修改如下內容:web

<?php
# application/config/config.php

// (...)

$config['enable_hooks']      = TRUE;
$config['composer_autoload'] = TRUE;

// (...)
複製代碼

將Luthier CI與您的應用程序鏈接

在hooks.php文件中,將Luthier CI掛鉤分配給$hook變量:api

<?php
# application/config/hooks.php

defined('BASEPATH') OR exit('No direct script access allowed');

// (...)

$hook = Luthier\Hook::getHooks();
複製代碼

在routes.php文件中,將Luthier CI路由分配給$route變量:數組

<?php
# application/config/routes.php

defined('BASEPATH') OR exit('No direct script access allowed');

// (...)

$route = Luthier\Route::getRoutes();
複製代碼

初始化 ( Initialization )

第一次執行Luthier CI時,會自動建立一些文件和文件夾:bash

  • routes/web.php: HTTP路由文件
  • routes/api.php: AJAX路由文件
  • routes/cli.php: CLI路由文件
  • controllers/Luthier.php: 假控制器,必須使用一些路線
  • middleware: 用於保存中間件文件的文件夾

在框架初始化期間,調用鉤子:app

Luthier\Hook::getHooks()返回一個帶有Luthier CI使用的鉤子的數組,包括啓動它所需的鉤子。composer

此時,Luthier CI分析並編譯上述前三個文件中定義的全部路由。框架

而後,當框架加載application/config/routes.php文件中的路由時,ui

Luthier\Route::getRoutes()返回一個數組,其中包含CodeIgniter理解的格式的路由。spa

如下全部內容都是框架的正常執行。

編寫權限 ( Writing permissions )
若是在建立Luthier CI基本文件期間出現錯誤,則多是因爲權限不足。確保該 application 文件夾具備寫入權限
相關文章
相關標籤/搜索