承接 simplydi/simplyrouter 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

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

simplydi/simplyrouter

Composer 安装命令:

composer require simplydi/simplyrouter

包简介

A simple PHP routing system for small apps

README 文档

README

A simple routing system in PHP

Notes

  • built for learning purpose
  • it is a very simple router. For more powerful features like route naming and middleware implementations, go for League Route or Symfony router
  • suitable only for small projects

Usage

include 'src/Router.php'; // or use composer: require 'vendor/autoload.php'

$route = new \SimplyDi\SimplyRouter\Router();

$route->match('/', function () {
    echo "Welcome us";
});

$route->match('/about', function () {
    echo "About us";
});

$route->match('/policy/privacy', function () {
    echo "PRIVACY us";
});

$route->match('/post/{slug}', function ($params) {
    $slug = $params['slug'];
    echo "Post with slug: " . $slug;
});

# using controller classes
$route->match('/{slug}', function ($params) {
    $slug = $params['slug'];
    return (new PageController)->single($slug);
});

$route->run(); // run the router

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2023-08-04