是否有独立的 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
相关文章