Is there an standalone PHP routing library?(是否有独立的 PHP 路由库?)
问题描述
我希望向 PHP 应用程序添加一些动态的、REST 风格的路由.我很想使用现有的路由库,这样我就不必重新发明轮子了.
I'm looking to add some dynamic, REST-esque routing to a PHP application. I'd love to use an existing routing library so I don't have to reinvent the wheel.
然而,当我看到像 Slim 和 F3 这样的东西时,它们都带有我不想要的东西——比如模板和 MVC——包括在内.因为我只想要路由,所以我的应用程序中最终会出现很多我不需要的框架代码.
However, when I look at things like Slim and F3, they all come with things I don't want--like templating and MVC--included. Since I just want routing, I'd end up with a lot of framework code in my application that I don't need.
有没有一个好的库只做路由?还是我坚持导入完整框架或重新发明轮子?
Is there a good library out there that only does routing? Or am I stuck with importing a full framework or reinventing the wheel?
推荐答案
试试Klein:
单个文件,独立且强大:
Single file, standalone and robust:
klein.php 是适用于 PHP 5.3+ 的闪电般快速的路由器"
"klein.php is a lightning fast router for PHP 5.3+"
- 灵活的正则表达式路由(受 Sinatra 启发)
- 一组用于快速构建网络应用的样板方法
- 几乎没有开销 => 2500+ 个请求/秒
https://github.com/chriso/klein.php
这篇关于是否有独立的 PHP 路由库?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:是否有独立的 PHP 路由库?


基础教程推荐
- Web 服务器如何处理请求? 2021-01-01
- php中的PDF导出 2022-01-01
- php 7.4 在写入变量中的 Twig 问题 2022-01-01
- 主题化 Drupal 7 的 Ubercart “/cart"页 2021-01-01
- PHPUnit 的 Selenium 2 文档到底在哪里? 2022-01-01
- Yii2 - 在运行时设置邮件传输参数 2022-01-01
- 将变量从树枝传递给 js 2022-01-01
- 如何在数学上评估像“2-1"这样的字符串?产生“1"? 2022-01-01
- php中的foreach复选框POST 2021-01-01
- 使用 scandir() 在目录中查找文件夹 (PHP) 2022-01-01