Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
<?php
//...
$di->set('annotations', function(){
//In development mode the memory adapter could be used
//it will read the annotations every time requested
//other adapter would store the parsed annotations in files/shared memory, etc
return new Phalcon\Annotations\Adapter\Memory();
});
$di->set('router', function() {
//Use the annotations router
$router = new \Phalcon\Mvc\Router\Annotations();
//This always read routes from RobotsController
//This will autoload that class and automatically will create the routes based
//on its annotations
$router->addResource('Robots');
//This will do the same as above but only if the handled uri starts with /robots
$router->addResource('Robots', '/robots');
return $router;
});
<?php
/**
* @RoutePrefix("/robots")
*/
class RobotsController extends Phalcon\Mvc\Controller
{
/**
* @Get("/")
*/
public function indexAction()
{
}
/**
* @Get("/edit/{id:[0-9]+}", name="edit-robot")
*/
public function editAction($id)
{
}
/**
* @Route("/save", methods={"POST", "PUT"}, name="save-robot")
*/
public function saveAction()
{
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.