Create a composer.json:
{
"autoload": {
"psr-0": {
"": "lib/"
}
}
}
Run
php composer.phar install
Or update your composer.json
php composer.phar update
Require the vendor/autoload.php file and create an instance of mersonal framework
// Require the vendor/autoload.php file
require_once __DIR__ . '/vendor/autoload.php';
// create an instance of mersonal framework
$app = new Florent\Mersonal();
// any route
$app->map('/foo', function() { // Code... });
// GET|POST|PUT|DELETE route
$app->get('/foo', function() { // Code... });
$app->post('/foo', function() { // Code... });
$app->put('/foo', function() { // Code... });
$app->delete('/foo', function() { // Code... });
// Dynamic routing
$app->map('/foo/{bar}', function($bar) { // Code... });
Update your composer.json:
"psr-0": {
"YourNamespace": "path/to/your/controllers/"
}
Run
php composer.phar update
Defined a route
$app->map('/foo', array(new Acme\FooController()), 'barAction'));
Update your composer.json:
"files": [
"lib/helpers.php"
]
Run
php composer.phar update
Use short route definition
map('/foo', function() { // Code... });
// no route matched
exit('Not found!');