PHPackages                             willitscale/streetlamp - 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. [HTTP &amp; Networking](/categories/http)
4. /
5. willitscale/streetlamp

ActiveLibrary[HTTP &amp; Networking](/categories/http)

willitscale/streetlamp
======================

A HTTP router application wrapper.

2.0.8(10mo ago)72271MITPHPCI passing

Since Jan 28Pushed 10mo ago1 watchersCompare

[ Source](https://github.com/willitscale/streetlamp)[ Packagist](https://packagist.org/packages/willitscale/streetlamp)[ RSS](/packages/willitscale-streetlamp/feed)WikiDiscussions main Synced today

READMEChangelog (10)Dependencies (7)Versions (30)Used By (0)

Streetlamp
==========

[](#streetlamp)

[![GitHub Workflow Status (with branch)](https://camo.githubusercontent.com/54e95ad614a9940288752d9032c4017fd91c248b2ba6c46e30e3116fb33d4859/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f77696c6c69747363616c652f7374726565746c616d702f7068702e796d6c)](https://github.com/willitscale/streetlamp/actions)[![Packagist License](https://camo.githubusercontent.com/88740234e8fc9e754b89a7b47c628c17d495a6a70cc98805a4e08592f6c80203/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f77696c6c69747363616c652f7374726565746c616d70)](https://github.com/willitscale/streetlamp/blob/main/LICENSE)[![Packagist Version](https://camo.githubusercontent.com/c597bcb5b22df21bf4d05701c7fe405e1b866eb455dd0cd9f1bb49bb0319c1f6/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f77696c6c69747363616c652f7374726565746c616d70)](https://packagist.org/packages/willitscale/streetlamp)[![GitHub last commit](https://camo.githubusercontent.com/fa3758e77bf3d304b649355d5813855cbfa1eb17121e736fb31a17f0ea56304b/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6173742d636f6d6d69742f77696c6c69747363616c652f7374726565746c616d70)](https://github.com/willitscale/streetlamp/commits/main)

Table of Contents
-----------------

[](#table-of-contents)

- [1. Introduction](#1-introduction)
- [2. Prerequisites](#2-prerequisites)
- [3. Setup](#3-setup)
- [3.1. Installing the library](#31-installing-the-library)
- [3.2. Application Wrapper](#32-application-wrapper)
- [3.3 Creating a Controller](#33-creating-a-controller)
- [3.4. Creating a Route](#34-creating-a-route)
- [4. PSR Compliance](#4-psr-compliance)
- [5. Further Reading](#5-further-reading)

1. Introduction
---------------

[](#1-introduction)

Streetlamp is a simple routing library that allows you to quickly prototype APIs. This library was built around the basic concepts of annotative routing, commonly found in Java libraries such as [JAX-RS](https://cxf.apache.org/docs/jax-rs.html) and [Spring](https://spring.io/). Although the way it works is inspired from the aforementioned Java libraries, it has a slightly unique implementation more fitting the PHP language.

2. Prerequisites
----------------

[](#2-prerequisites)

To keep up with modern standards this library was built using PHP 8.4 and therefore will only run in said environment or greater. Due to the speed of which PHP is evolving, it is recommended to always use the latest stable version of PHP. Finally, this project requires composer and the [PSR-4 Autoload standard](https://www.php-fig.org/psr/psr-4/).

3. Setup
--------

[](#3-setup)

### 3.1. Installing the library

[](#31-installing-the-library)

Simply include Streetlamp in your project with the composer command:

```
composer require willitscale/streetlamp
```

### 3.2. Application Wrapper

[](#32-application-wrapper)

To run your application through the Streetlamp wrapper all you need to do is instantiate the `Router` class and call `route`. The `Router` will use a `RouteBuilder` to scan all of your namespaces in the `composer.json` (excluding test namespaces by default) and setup corresponding routes.

Here's all the code you need to get going:

```
