百科.dev
全部条目在线工具AI 编程趋势榜开源项目技术资讯提交条目
登录
< 返回工具列表
D

dispatch

> 编程语言
开源

pHP 应用程序的小型库

537 stars0 点赞1 次浏览
访问官网GitHub

工具介绍

pHP 应用程序的小型库

dispatch

  • a tiny library for quick and easy PHP apps
  • requires at least PHP 8.x

functions

Below is the list of functions provided by dispatch.

…

Here's a sample of how you'd usually use them in an app.

…

Once dispatch(...) is called, it will try to match the current request to any of the mapped routes via route(...). When it finds a match, it will then do the following sequence:

  1. Execute all named parameter bindings from bind(...)
  2. Execute all global middleware and matching middleware from apply(...)
  3. Invoke the handler for the matching route.

Because of this sequence, it means that any transformations done by bind(...) mappings will have already updated the values inside the $params array that's forwarded down the execution chain.

URL Rewriting as a standalone PHP file

If you are running Dispatch as a stanalone PHP file, either on the root path or not (eg: path/to/search.php), this can cause errors with path matching.

You can use the DISPATCH_PATH_PREFIX global to mimic URL rewriting used in other libraries;

php
<?php
// file: path/to/search.php

// NOTE: this must be defined before calling the dispatch.php file
define('DISPATCH_PATH_PREFIX', '/path/to/search.php');

require __DIR__ . '/dispatch.php';

route('GET', '/testing', function() {
  echo "test page on subpath " . $_SERVER['REQUEST_URI'];
});

dispatch();

license

MIT

Issues· 0 开放

查看全部 Issues在 GitHub 打开

暂无开放 Issues,或尚未同步最近议题。

> 标签

PHPframeworkmicro-frameworkmicroframeworkmiddleware

暂无评论,来聊聊你的看法吧

> 工具信息

发布日期2026年8月1日
最后更新2026年9月17日
分类编程语言
定价开源

> 相关工具

T
TypeScript
JavaScript 的超集,为前端与全栈提供静态类型
P
Python
通用编程语言,广泛用于 Web、数据与 AI
G
Go
Google 推出的简洁高效系统语言