cetver / yii2-routes-collector
Yii框架2.0的路线收集器
1.0.2
2020-02-01 21:37 UTC
Requires
- php: >=5.6.0
- yiisoft/yii2: ~2.0.0
Requires (Dev)
- codeception/base: ^2.2.3
- codeception/specify: ~0.4.3
- codeception/verify: ~0.3.1
- guzzlehttp/guzzle: ^6.0
- satooshi/php-coveralls: ^1.0
- yiisoft/yii2-bootstrap: ~2.0.0
This package is auto-updated.
Last update: 2024-09-16 03:51:40 UTC
README
提供收集、保存和操作Web应用程序路线的工具。
安装
安装此扩展的首选方法是使用 composer。
运行以下命令之一
composer require --prefer-dist cetver/yii2-routes-collector
或在您的 composer.json
文件的 require 部分添加以下内容
"cetver/yii2-routes-collector": "^1.0"
配置
运行迁移命令
./yii migrate --migrationPath=@cetver/RoutesCollector/migrations
更新控制台应用程序配置文件
'controllerMap' => [ 'routes' => 'cetver\RoutesCollector\commands\RoutesController', ],
使用方法
创建以下格式的 web应用程序配置文件
<?php return [ [], // the configuration of the first web-app [], // the configuration of the second web-app ];
运行收集命令
./yii routes/collect <path-to-config-file>
如果您需要向用户显示路线,请运行 "routes/extract-message" 命令
./yii routes/extract-messages '{"messagePath":"@app/messages","languages":["en-US","ru-RU"]}' routes
"routes/extract-message" 命令参数
- 第一个参数是 "message/extract" 命令选项,格式为JSON
- 第二个参数是 翻译函数的第一个参数
现在您可以通过编辑以下文件来设置别名/翻译
@app/messages/en-US/routes.php
@app/messages/ru-RU/routes.php
测试
运行以下命令
composer create-project --prefer-source cetver/yii2-routes-collector
创建虚拟主机(nginx 示例)
- basic.cetver-yii2-routes-collector 指向 "tests/_data/apps/basic/web"
- frontend.cetver-yii2-routes-collector 指向 "tests/_data/apps/advanced/backend/web"
- backend.cetver-yii2-routes-collector 指向 "tests/_data/apps/advanced/frontend/web"
在此处更改数据库配置 这里 或运行以下命令
export DB=sqlite
运行以下命令
cd yii2-routes-collector
vendor/bin/codecept run unit,functional
示例
在运行测试后,打开以下链接
- http://basic.cetver-yii2-routes-collector/examples/default/tree
- http://backend.cetver-yii2-routes-collector/examples/default/tree
如果您正确遵循说明,您应该会看到以下截图中的页面