ngames/framework

NGames 框架是一个简单的 PHP 框架,为 https://www.worldwar.fr 和 https://www.guide-tnt.fr 网站开发。

0.4.0 2024-07-21 21:01 UTC

This package is auto-updated.

Last update: 2024-09-21 21:16:54 UTC


README

Build Status License Last release

Coverage

安装

使用 composer 安装应用程序: composer require ngames/framework。或者您可以通过在 require 对象中添加以下行来更新 composer.json 文件

{
    "require": {
        "ngames/framework": "~0.3"
    }
}

用法

配置文件

您需要使用 INI 格式编写配置文件。通常,该文件名为 config.ini,位于项目根目录下的 config 文件夹中。以下是一个包含所有支持配置键的示例

# Database configuration
database.host       = "127.0.0.1"
database.username   = "db_user"
database.password   = "db_password"
database.name       = "db_name"

# Log configuration (destination must be a file), the level is the minimum level for logging messages
log.destination     = "./logs/application.log"
log.level           = "debug"

# Whether the debug mode is enabled or not (default is false)
debug               = "true"

应用程序初始化

在项目根目录的 public 文件夹中,创建一个名为 index.php 的文件,并包含以下内容

<?php
defined("ROOT_DIR") || define ("ROOT_DIR", dirname(__DIR__));
chdir(ROOT_DIR);

// Initialize and run the application
require_once ROOT_DIR . '/vendor/autoload.php';
\Ngames\Framework\Application::initialize(ROOT_DIR . '/config/config.ini')->run();

这就是启动应用程序所需的所有内容。

控制器

控制器位于项目根目录下的 src 文件夹中。它们按模块组织,位于代表模块的文件夹中。默认模块是 Application