Last active
December 11, 2015 04:09
-
-
Save phalcon/4543132 to your computer and use it in GitHub Desktop.
This file contains 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 | |
//... | |
$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; | |
}); |
This file contains 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 | |
/** | |
* @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