Flexibility is power!
PHP JavaScript
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
Cobalt
package
test
.gitignore
LICENSE.txt
README.md
composer.json
demo.php

README.md

Cobalt (beta)

Flexibility is power!

<?php
require "cobalt.php";

Cobalt::setup();

Cobalt::bind('/', function ($view) {
    return $view('partials/landing.php');
});

Cobalt::bind('/about/:what', function ($view, $http) {
    return $view("partials/about_".$http('get:what').".php");
});

Cobalt::handle('get:url');

Cobalt is a boilerplate that makes URL rewriting & routing a childsplay in your PHP applications. It also bundles a simple, yet powerful, dependency injector plus an easy event API that ease components interworking. If you need a simple, easy to deploy structure for your MVC application, Cobalt is just what you need: no bloated abstraction layers, no complex components hierarchy, just high level, developper-friendly, easy to use components.

Requirements

Cobalt is designed to work on the widely spread LAMP stack, the only formal dependency is PHP 5.3 (or above).

Basics

Cobalt needs no configuration by default, simply include cobalt.php packaged script and run Cobalt::setup() to initialize the environment.

The next step is to define our URL using a very simple URL template and bind them to behaviors described using callbacks. It is important to note here that you can describe your entire application at a single place if you want to: Cobalt does not require you to create several controllers classes in separate files.

Finally, at the bottom of your script, just call Cobalt::handle() to launch your application. Cobalt will then use the handle parameter (basically the URL) to determine the corresponding callback, what it returns will be sent to the browser.

Routing

Work in progress...

Dependency Injection

Work in progress...

Events API

Work in progress...

Documentation

Work in progress...