PHPackages                             oscarpalmer/quest - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Framework](/categories/framework)
4. /
5. oscarpalmer/quest

AbandonedArchivedLibrary[Framework](/categories/framework)

oscarpalmer/quest
=================

A PHP router.

v2.2.0(8y ago)9572MITPHPPHP &gt;=7.0

Since May 6Pushed 4y ago1 watchersCompare

[ Source](https://github.com/oscarpalmer/quest)[ Packagist](https://packagist.org/packages/oscarpalmer/quest)[ Docs](https://github.com/oscarpalmer/quest)[ RSS](/packages/oscarpalmer-quest/feed)WikiDiscussions main Synced 3d ago

READMEChangelog (9)Dependencies (3)Versions (11)Used By (0)

Quest
=====

[](#quest)

[![PHP version](https://camo.githubusercontent.com/988822df59e754bff46b19dfa0cdc33a207576dd6ae3d81c67369a45f9c876c4/68747470733a2f2f62616467652e667572792e696f2f70682f6f7363617270616c6d657225324671756573742e737667)](http://badge.fury.io/ph/oscarpalmer%2Fquest) [![Build Status](https://camo.githubusercontent.com/a6dae2d550298d416497e9b59ce649f0a32edf51a8849f07f37fc4cac889f7a5/68747470733a2f2f7472617669732d63692e6f72672f6f7363617270616c6d65722f71756573742e706e673f6272616e63683d6d6173746572)](https://travis-ci.org/oscarpalmer/quest) [![Coverage Status](https://camo.githubusercontent.com/a020df123bf6f0b6f3a87fdc699abb40314e983c4d328e55845d236cfe3f7ee4/68747470733a2f2f636f6465636f762e696f2f67682f6f7363617270616c6d65722f71756573742f6272616e63682f6d61737465722f67726170682f62616467652e737667)](https://codecov.io/gh/oscarpalmer/quest)

Quest is a router for PHP `>=7`.

The name
--------

[](#the-name)

> In particular, questing heroes of all stripes seek after the fabled Daedric artifacts for their potent combat and magical benefits.

— Haderus of Gottlesfont, *[Modern Heretics](http://uesp.net/wiki/Lore:Modern_Heretics)*

Getting started
---------------

[](#getting-started)

### Installation

[](#installation)

Quest is available via [Composer &amp; Packagist](//packagist.org/packages/oscarpalmer/quest).

```
{
  "require": {
    "oscarpalmer/quest": "2.2.*",
    "oscarpalmer/shelf": "2.3.*"
  }
}
```

Quest uses [Shelf](//github.com/oscarpalmer/shelf), a Rack-like interface for PHP made by me. It's pretty cool.

### Basic usage

[](#basic-usage)

```
use oscarpalmer\Quest\Quest;

$quest = new Quest;

$quest->get("/", function () {
    return "Hello, world!";
});

$quest->run();
```

And that's it! But I'm sure you'll want to know more about [routing](#routing) and the [API](#api).

Routing
-------

[](#routing)

If you've ever used something like [Sinatra](http://sinatrarb.com), then routing with Quest shouldn't be too difficult.

There are three kinds of routing parameters that'll make working with complex routes a piece of cake.

- `*`: matches just about everything; i.e `.*?`.
- `:param`: matches any word character; i.e `\w+`.
- `(anything)`: optional match for `anything`; i.e. `(anything)?`.

### Examples of routes

[](#examples-of-routes)

```
# the following route will match /a/simple/path
$quest->get("/a/simple/path", $callback);

# the following route will match
# /path/to/dir/file.extension and /a/b/c/d/e/f/b/g/h.i
$quest->get("/*/:file.:ext", $callback);

# optional parameters should be wrapped in parentheses;
# the following route will therefore match both
# /path/to/dir/file.extension and /path/to/dir/file
$quest->get("/*/:file(.:ext)", $callback);
```

### Callbacks

[](#callbacks)

Echoes are captured and flushed. Please use return statements to output stuff.

### Error handlers

[](#error-handlers)

Having an error handler ready for when you or the user hits a bump is always useful. Status-specific handlers takes precedence over the wildcard handler, which in turn take precedence over the default handlers.

```
# Calling handlers
$quest->error();    # The error-handler defaults to 500.
$quest->error(401); # You can choose the error, too.

# Defining handlers
$quest->error(401, function () {}); # Status-specific errors are possible, too.
```

### Server stuff

[](#server-stuff)

Now, Quest can't do much if your server isn't set up properly, so here's two snippets for "proper" URL rewriting with [Apache](http://httpd.apache.org) and [nginx](http://nginx.org).

#### Apache

[](#apache)

```
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule . /index.php [L]
```

#### nginx

[](#nginx)

```
try_files $uri /index.php;
```

API
---

[](#api)

```
# Constructor
$quest = new Quest($a, $b, $c);     #  Optional parameters; array of routes, and Request
                                    #  and Response objects from Shelf; useful for testing

# Constants and properties
$quest::VERSION;                    #  Current Quest version number
$quest->errors;                     #  Array of error callbacks with status codes as keys
$quest->filters;                    #  Array of filters with at most two children; "after" and "before"
$quest->parameters;                 #  Object of route parameters
$quest->request;                    #  Shelf Request object
  $quest->cookies;                  #    $_COOKIE object belonging to the Request object
  $quest->data;                     #    $_POST object
  $quest->files;                    #    $_FILES object
  $quest->query;                    #    $_GET object
  $quest->server;                   #    $_SERVER object
  $quest->session;                  #    $_SESSION object
$quest->response;                   #  Shelf Response object
$quest->routes;                     #  Array of routes

# Filter methods
$quest->after($path, $callback);    #  Add an after filter with a path to run after routing
$quest->before($path, $callback);   #  Add a before filter with a path to run before routing
                                    #  $path must be a string, and $callback must be a callable

# Route methods
$quest->delete($path, $callback);   #  Add a DELETE route;
$quest->get($path, $callback);      #  Add a GET (and HEAD) route
$quest->post($path, $callback);     #  Add a POST route
$quest->put($path, $callback);      #  Add a PUT route
                                    #  $path must be a string and $callback must be a callable

# Error method
$quest->error($status, $callback);  #  Add or run an error callback; will run an already defined
                                    #  or default callback if no $callback is supplied
                                    #  $status can be a valid status code or null (500 error);
                                    #  $callback must be a callable if supplied

# Helper methods
$quest->contentType($optional);     #  Get or set the content type of the response
$quest->header($name, $optional);   #  Get or set a response header

# Run method
$quest->run();                      #  Let the questing (routing) begin!
                                    #  Will run filters and the first matching route's callback
```

License
-------

[](#license)

MIT Licensed; see [the LICENSE file](LICENSE) for more info.

###  Health Score

30

—

LowBetter than 64% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity16

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity64

Established project with proven stability

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~175 days

Recently: every ~282 days

Total

9

Last Release

2990d ago

Major Versions

v1.3.0 → v2.0.02017-10-27

PHP version history (2 changes)v1.0.0PHP &gt;=5.3.0

v2.0.0PHP &gt;=7.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/5e5647f0434aa5576876d278b8cffa863b69d5cc26acb5e7f08c8ef5816a689c?d=identicon)[oscarpalmer](/maintainers/oscarpalmer)

---

Top Contributors

[![oscarpalmer](https://avatars.githubusercontent.com/u/27967?v=4)](https://github.com/oscarpalmer "oscarpalmer (46 commits)")

---

Tags

phprouterframeworkrouter

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/oscarpalmer-quest/health.svg)

```
[![Health](https://phpackages.com/badges/oscarpalmer-quest/health.svg)](https://phpackages.com/packages/oscarpalmer-quest)
```

###  Alternatives

[slim/slim

Slim is a PHP micro framework that helps you quickly write simple yet powerful web applications and APIs

12.2k49.9M1.3k](/packages/slim-slim)[developermarius/simple-router

Simple, fast PHP router that is easy to get integrated and in almost any project. Heavily inspired by the Laravel router.

112.4k](/packages/developermarius-simple-router)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
