jacko/router
Composer 安装命令:
composer require jacko/router
包简介
Simple router
README 文档
README
How to Install
Installation via composer is easy:
composer require jacko/router:dev-master
How to Use
Write into your index.php:
require('vendor/autoload.php'); // $router = new Jacko\Router(); $router->path = 'config/routes.php'; $router->start();
Check your .htaccess, it's must looking like that:
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .* index.php [L]
An Example Route
Place into your config/routes.php
Route::get('/', 'HomeController@index'); Route::any('/page', 'HomeController@page'); Route::post('/ajax', 'HomeController@ajax'); Route::get('/user/{id}', function($id) { var_dump($id); }); Route::get('/{any}', 'HomeController@error404');
Dependency Injection in your Controllers
Please, make sure that your Models contains call methods like all(), first(), etc
class HomeController { public function __construct(User $user, Order $order) { $this->user = $user; $this->order = $order; } public function page(Page $page) { $users = $this->user->all(); $home = $page->first(); var_dump($users, $home); } }
统计信息
- 总下载量: 24
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 0
- 依赖项目数: 1
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2016-11-19