amhol/extendable-routing

此包的最新版本(1.0)没有可用的许可证信息。

为Laravel-4路由器添加扩展方法,允许您添加自定义路由扩展

1.0 2014-06-03 11:12 UTC

This package is not auto-updated.

Last update: 2024-09-24 07:52:38 UTC


README

为Laravel-4路由器添加扩展方法,允许您添加自定义路由扩展

安装

首先,通过Composer安装此包。编辑您的项目composer.json文件,以需要amhol/extendable-routing

"require": {
    "amhol/extendable-routing": "1.*"
}

接下来,从终端更新Composer

composer update

此操作完成后,最后一步是添加服务提供者。打开app/config/app.php,并在提供者数组中添加一个新项。

'AMHOL\ExtendableRouting\ExtendableRoutingServiceProvider'

用法

首先,您需要添加您的路由扩展,我更喜欢通过添加一个如下的app/routeextensions.php文件来完成此操作

<?php

/*
|--------------------------------------------------------------------------
| Application Route Extensions
|--------------------------------------------------------------------------
|
| Here is where you can extend the router with your own methods.
| It's a breeze. Simply tell the Laravel Router the methods it should 
| respond to and give it the Closure to execute when that method is 
| called.
|
*/

// Route::extend('api', function($resources, $actions = ['index', 'show', 'update', 'create']) {
//     // my custom extension
//     // Route::get($resources, ...);
// });

然后,将以下内容添加到app/start/global.php文件的底部

require app_path().'/routeextensions.php';

然后,您可以通过routes.php中的Route外观正常访问您的自定义路由方法。