Baike.dev
All toolsAI codingTrendingOpen sourceNewsSubmit
Log in
< Back to tools
D

dispatch

> 编程语言
Open source

a tiny library for quick and easy PHP apps

537 stars0 likes1 views
WebsiteGitHub

About

a tiny library for quick and easy PHP apps

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 open

View all issuesOpen on GitHub

No open issues yet, or sync has not completed.

> Tags

PHPframeworkmicro-frameworkmicroframeworkmiddleware

No comments yet. Be the first to share.

> Details

PublishedAug 1, 2026
UpdatedSep 17, 2026
Category编程语言
PricingOpen source

> Related tools

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