tailwindsllc / modus
4.3.3
2019-05-19 17:43 UTC
Requires
- php: >=5.5.0
- aura/accept: ~2.0
- aura/auth: ~2.0
- aura/cli: ~2.0
- aura/di: ~2.1
- aura/html: ~2.1.0
- aura/http: ~1.0.1
- aura/router: ~2.0
- aura/session: ~1.0.1
- aura/sql: ~2.0
- aura/sqlquery: ~2.0
- aura/view: ~2.0.0
- aura/web: ~2.0
- brandonsavage/booboo: ~0.4
- monolog/monolog: ~1.5
Requires (Dev)
- mockery/mockery: 0.9.0
- phpunit/phpunit: 3.7.*
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']]
],
);