Skip to content

Instantly share code, notes, and snippets.

@mrspartak
Created December 19, 2013 20:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mrspartak/790eddb6619aff75634b to your computer and use it in GitHub Desktop.
Save mrspartak/790eddb6619aff75634b to your computer and use it in GitHub Desktop.
<?
define('ROOTDIR', realpath( dirname(__FILE__) . '/../../' ) );
//Register app dirs
$loader = new \Phalcon\Loader();
$loader->registerDirs(
array(
ROOTDIR . 'app/models/',
ROOTDIR . 'app/vendor/'
)
)->register();
//setting up DI
$di = new \Phalcon\DI\FactoryDefault();
$di->setShared('session', function() {
$session = new Phalcon\Session\Adapter\Files();
$session->start();
return $session;
});
$app = new Phalcon\Mvc\Micro();
$app->setDI($di);
$app->before(function() use ($app) {
if($app->session->has("logged_in") !== true) {
$app->response->redirect("/login");
return false;
}
});
$app->get('/', function () use ($app) {
echo '/';
});
$app->get('/login', function () use ($app) {
echo '/login';
});
$app->handle();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment