是否有独立的 PHP 路由库? [英] Is there an standalone PHP routing library?

查看:26
本文介绍了是否有独立的 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 路由库?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆