yiisoft/file-router
最新稳定版本:1.0.0
Composer 安装命令:
composer require yiisoft/file-router
包简介
Convention-based file structure router
README 文档
README
Yii File Router
The package provides a convention-based router middleware that chooses controller based on its namespace and class name.
Requirements
- PHP 8.1 or higher.
Installation
The package could be installed with Composer:
composer require yiisoft/file-router
General usage
-
Add
\Yiisoft\FileRouter\FileRouterto the list of middlewares in your application configuration,web/params.php:return [ 'middlewares' => [ // ... Router::class, \Yiisoft\FileRouter\FileRouter::class, // or [ 'class' => FileRouter::class, 'withNamespace()' => ['App'], 'withBaseControllerDirectory()' => ['Controller'], ], // ... ] ];
-
Configure the file router for your needs.
Note:
FileRoutergoes after regularRouterto serve as a fallback in case explicitly defined route is not found.
By default, the following structure of the app could be used assuming App points to src directory:
src
Controller
User
Profile
IndexController.php
BlogController.php
UserController.php
IndexController.php
Here's how it works:
GET /→IndexController::index()GET /user→UserController::index()POST /user→UserController::create()GET /user/blog/view→User/BlogController::view()GET /user/profile→User/Profile/IndexController::index()
Documentation
For additional information, check the following docs:
- Guide: English, Português - Brasil
- Internals
If you need help or have a question, the Yii Forum is a good place for that. You may also check out other Yii Community Resources.
License
The Yii File Router is free software. It is released under the terms of the BSD License.
Please see LICENSE for more information.
Maintained by Yii Software.
Support the project
Follow updates
统计信息
- 总下载量: 24
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 7
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: BSD-3-Clause
- 更新时间: 2023-12-28