Skip to content

Instantly share code, notes, and snippets.

@danielsilver2
Last active August 10, 2016 13:32
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 danielsilver2/524aba806e1792e68eac58f5445371f2 to your computer and use it in GitHub Desktop.
Save danielsilver2/524aba806e1792e68eac58f5445371f2 to your computer and use it in GitHub Desktop.
<?php
use Phalcon\Di\FactoryDefault;
use Phalcon\Mvc\Micro;
error_reporting(E_ALL);
define('APP_PATH', realpath('..'));
try {
/**
* @var FactoryDefault $di
*/
$di = new FactoryDefault();
/**
* Include Services
*/
include APP_PATH . '/config/services.php';
/**
* Call the autoloader service. We don't need to keep the results.
*/
$di->getLoader();
/**
* Starting the application
* Assign service locator to the application
*/
$app = new Micro($di);
/**
* Include Application
*/
include APP_PATH . '/app.php';
/**
* Handle the request
*/
$app->handle();
} catch (\Exception $e) {
echo $e->getMessage() . '<br>';
echo '<pre>' . $e->getTraceAsString() . '</pre>';
}
<?php
$di->set('router', function()
{
$router = new \Phalcon\Mvc\Router\Annotations(false);
$router->setDefaultNamespace('GIS\Controller');
$router->addResource('User','/user');
var_dump($router);
return $router;
});
<?php namespace GIS\Controller;
use \Phalcon\Mvc\Controller;
/**
* @RoutePrefix("/user")
*/
class UserController extends Controller
{
/**
* @Get("/")
*/
public function indexAction()
{
return 'login';
}
/**
* @Get("/hello", name="hello")
*/
public function helloAction()
{
return 'hello';
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment