-
-
Save mrspartak/790eddb6619aff75634b 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
<? | |
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