定制 viloveul/router 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

viloveul/router

Composer 安装命令:

composer require viloveul/router

包简介

Http Router for handling request path

README 文档

README

Build Status Total Downloads Latest Stable Version

Installation

make sure your php version > 7.0

composer require viloveul/router

HOW

require __DIR__ . '/vendor/autoload.php';

// init collection object
$collection = new Viloveul\Router\Collection();

// declare class controller for handler
class MyController
{
	public function look($name)
	{
		return $name;
	}
}

// declare hello handler from my controller
$helloRoute = new Viloveul\Router\Route('GET /hello/:name', [MyController::class, 'look']);
// or 
// $helloRoute = new Viloveul\Router\Route('GET /hello/:name', [MyController::class, 'look']);
// add foo to collection
$collection->add($helloRoute);

// declare foo handler
$fooRoute = new Viloveul\Router\Route('GET /foo/{:bar}', function($bar) {
	return $bar;
});
// add foo to collection
$collection->add($fooRoute);

// declare test handler
$testRoute = new Viloveul\Router\Route('/test/:name', [
	'method' => 'GET|POST|PUT|PATCH',
	'handler' => function ($name) {
		return $name;
	}
]);
// add test to collection
$collection->add($testRoute);

// init object dispatcher with collection
$router = new Viloveul\Router\Dispatcher($collection);

// in action

$router->dispatch('GET', Zend\Diactoros\UriFactory::createUri('/hello/zafex'));
$route1 = $router->routed();

$router->dispatch('GET', Zend\Diactoros\UriFactory::createUri('/foo/hello-world'));
$route2 = $router->routed();

$router->dispatch('GET', Zend\Diactoros\UriFactory::createUri('/test/fajrul-akbar-zuhdi'));
$route3 = $router->routed();

var_dump($route1, $route2, $route3);

统计信息

  • 总下载量: 184
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 1
  • 点击次数: 0
  • 依赖项目数: 1
  • 推荐数: 0

GitHub 信息

  • Stars: 1
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2018-12-29

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固