乐趣区

Luthier-CI安装-Installation

安装 (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 文件夹并执行以下命令:

composer require luthier/luthier

启用 Composer autoloadhooks

要使 Luthier CI 工作,必须在框架中启用 Composer 自动加载和挂钩。在文件中 config.php 修改以下内容:

<?php
# application/config/config.php

// (...)

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

// (...)

将 Luthier CI 与您的应用程序连接

在 hooks.php 文件中,将 Luthier CI 挂钩分配给 $hook 变量:

<?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 时,会自动创建一些文件和文件夹:

  • routes/web.php: HTTP 路由文件
  • routes/api.php: AJAX 路由文件
  • routes/cli.php: CLI 路由文件
  • controllers/Luthier.php: 假控制器,必须使用一些路线
  • middleware: 用于保存中间件文件的文件夹

在框架初始化期间,调用钩子:

LuthierHook::getHooks() 返回一个带有 Luthier CI 使用的钩子的数组,包括启动它所需的钩子。

此时,Luthier CI 分析并编译上述前三个文件中定义的所有路由。

然后,当框架加载 application/config/routes.php 文件中的路由时,

LuthierRoute::getRoutes() 返回一个数组,其中包含 CodeIgniter 理解的格式的路由。

以下所有内容都是框架的正常执行。

编写权限 (Writing permissions)

如果在创建 Luthier CI 基本文件期间出现错误,则可能是由于权限不足。确保该 application 文件夹具有写入权限

退出移动版