Skip to content

Instantly share code, notes, and snippets.

@slav123
Created July 10, 2014 04:38
Show Gist options
  • Save slav123/1ba8068d50a806d8f681 to your computer and use it in GitHub Desktop.
Save slav123/1ba8068d50a806d8f681 to your computer and use it in GitHub Desktop.
<?php
use Phalcon\DI\FactoryDefault,
Phalcon\Mvc\Micro,
Phalcon\Http\Response,
Phalcon\Http\Request;
$di = new FactoryDefault();
//Using an anonymous function, the instance will be lazy loaded
$di["response"] = function () {
return new Response();
};
$di["request"] = function() {
return new Request();
};
$app = new Micro();
$app->setDI($di);
$app->get('/api', function () use ($app) {
echo "<h1>Welcome</h1>";
});
$app->post('/api', function() use ($app) {
$post = $app->request->getPost();
print_r($post);
});
$app->handle();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment