Created
July 10, 2014 04:38
-
-
Save slav123/1ba8068d50a806d8f681 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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