modus/framework

该软件包已废弃,不再维护。未建议替代软件包。

Modus框架,为Aura和其他库的许多组件提供基本支持。

4.3.3 2019-05-19 17:43 UTC

This package is auto-updated.

Last update: 2024-05-05 11:53:03 UTC


README

(注意:此README仍在进行中。)

Modus框架是一组通过Composer包含并通过“粘合代码”连接在一起,使组件作为一个单元有用的组件集合。

Modus使用了Aura的许多组件,以及一些Symfony组件和其他组件。

安装Modus

在克隆并检出存储库后,您将使用Composer安装依赖项。

安装这些组件后,您可以运行Modus命令行,它将文件放置在正确的目录结构中。

$ php vendor/bin/modus

Modus预期用作应用程序的完整框架,在根目录中操作。它使用htaccess文件将所有调用路由到public/目录中的索引文件。以下vhost配置是推荐的。

<VirtualHost *:80>
    ServerName example.com
    DocumentRoot /path/to/modus/public
    
    #Custom log file locations
    LogLevel warn
    ErrorLog   /path/to/modus/logs/error.log
    CustomLog  /path/to/modus/logs/access.log combined

    php_flag log_errors On
    php_value error_log  /path/to/modus/logs/php_errors.log

    <Directory /path/to/modus/public>
        DirectoryIndex index.php
        AllowOverride All
        Order allow,deny
        Allow from all
    </Directory>
</VirtualHost>

Modus配置文件

Modus使用一个配置系统,该系统通过Aura的依赖注入包实现依赖反转。

此外,还有一些文件您需要根据自己的设置进行修改

  • config.php - 该文件包含您的应用程序的配置选项。
  • routes.php - 该文件包含路由信息。已提供一些示例路由,您可以复制并重复使用。

配置路由

路由通常是应用程序中最复杂的一部分,但目标是使它们尽可能简单。

在最基本的情况下,路由有一个键,该键命名了路由,值是一个包含两个键的数组:路由本身和路由的参数。

<?php

array(
    "dashboard" => [
        "path" => "/dashboard",
        "args" => ["values" => ['controller' => 'dashboard', 'action' => 'index']]
    ],
);

当然,一些路由比这更复杂,需要额外的选项。例如,为了在路由的末尾指定ID值,您可以在args数组中添加一个params键,如下所示

<?php

array(
    "dashboard" => [
        "path" => "/dashboard/{:id}",
        "args" => ["values" => ['controller' => 'dashboard', 'action' => 'index'], 'params' => ['id' => '(/d+)']]
    ],
);

请注意,所有参数规则都遵循Aura.Router包。更多详情请查看文档。

如果您有复杂的命名空间要求,也可以指定到控制器的完全限定的命名空间路径

<?php

array(
    "dashboard" => [
        "path" => "/dashboard",
        "args" => ["values" => ['controllerns' => 'Full\Namespace\Goes\Here', 'action' => 'index']]
    ],
);