如何安装 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 文件夹具备写入权限
相关文章
相关标签/搜索