PHPackages                             netom/bulletphp - 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. netom/bulletphp

ActiveLibrary[Framework](/categories/framework)

netom/bulletphp
===============

A heierarchical resource-oriented micro-framework built on nested closures instead of route-based callbacks

v1.7.1(5y ago)02.4kBSDPHPPHP &gt;=5.6

Since Jan 24Pushed 5y ago1 watchersCompare

[ Source](https://github.com/netom/bulletphp)[ Packagist](https://packagist.org/packages/netom/bulletphp)[ Docs](http://bulletphp.com)[ RSS](/packages/netom-bulletphp/feed)WikiDiscussions master Synced today

READMEChangelogDependencies (2)Versions (28)Used By (0)

Bullet
======

[](#bullet)

Bullet is a resource-oriented micro PHP framework built around HTTP URIs. Bullet takes a unique functional-style approach to URL routing by parsing each path part independently and one at a time using nested closures. The path part callbacks are nested to produce different responses and to follow and execute deeper paths as paths and parameters are matched.

[![Build Status](https://camo.githubusercontent.com/d782794447601be1e792d31711b45ba4b211990aa77923e667259d6f026a0e4a/68747470733a2f2f7472617669732d63692e6f72672f766c756361732f62756c6c65747068702e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/vlucas/bulletphp)

PROJECT MAINTENANCE RESUMES
---------------------------

[](#project-maintenance-resumes)

Bullet becomes an active project again. Currently there's a changing of the guard. Feel free to further use and contribute to the framework.

Requirements
------------

[](#requirements)

- PHP 5.6+ (PHP 7.1 recommended)
- [Composer](http://getcomposer.org) for all package management and autoloading (may require command-line access)

Rules
-----

[](#rules)

- Apps are **built around HTTP URIs** and defined paths, not forced MVC (but MVC-style separation of concerns is still highly recommenended and encouraged)
- Bullet handles **one segment of the path at a time**, and executes the callback for that path segment before proceesing to the next segment (path callbacks are executed from left to right, until the entire path is consumed).
- If the entire path cannot be consumed, a 404 error will be returned (note that some callbacks may have been executed before Bullet can know this due to the nature of callbacks and closures). Example: path `/events/45/edit` may return a 404 because there is no `edit` path callback, but paths `events` and `45` would have already been executed before Bullet can know to return a 404. This is why all your primary logic should be contained in `get`, `post`, or other method callbacks or in the model layer (and not in the bare `path` handlers).
- If the path can be fully consumed, and HTTP method handlers are present in the path but none are matched, a 405 "Method Not Allowed" response will be returned.
- If the path can be fully consumed, and format handlers are present in the path but none are matched, a 406 "Not Acceptable" response will be returned.

Advantages
----------

[](#advantages)

- **Super flexible routing**. Because of the way the routing callbacks are nested, Bullet's routing system is one of the most flexible of any other PHP framework or library. You can build any URL you want and respond to any HTTP method on that URL. Routes are not restricted to specific patterns or URL formats, and do not require a controller with specific method names to respond to specific HTTP methods. You can nest routes as many levels deep as you want to expose nested resources like `posts/42/comments/943/edit` with a level of ease not found in most other routing libraries or frameworks.
- **Reduced code duplication (DRY)**. Bullet takes full advantage of its nested closure routing system to reduce a lot of typical code duplication required in most other frameworks. In a typical MVC framework controller, some code has to be duplicated across methods that perform CRUD operations to run ACL checks and load required resources like a Post object to view, edit or delete. With Bullet's nested closure style, this code can be written just once in a path or param callback, and then you can `use` the loaded object in subsequent path, param, or HTTP method handlers. This eliminates the need for "before" hooks and filters, because you can just run the checks and load objects you need before you define other nested paths and `use` them when required.

Installing with Composer
------------------------

[](#installing-with-composer)

Use the [basic usage guide](http://getcomposer.org/doc/01-basic-usage.md), or follow the steps below:

Setup your `composer.json` file at the root of your project

```
{
    "require": {
        "vlucas/bulletphp": "~1.7"
    }
}

```

Install Composer

```
curl -s http://getcomposer.org/installer | php

```

Install Dependencies (will download Bullet)

```
php composer.phar install

```

Create `index.php` (use the minimal example below to get started)

```
