public function resource($route, $controller, $additionals = []) { $collection = new \Phalcon\Mvc\Micro\Collection(); $collection->setPrefix($route); $collection->setHandler(new $controller()); $collection->get('/', 'getAll'); $collection->get('/{id}', 'get'); $collection->post('/', 'create'); $collection->put('/{id}', 'update'); $collection->delete('/{id}', 'delete'); $this->mount($collection); }
public function testMicroCollectionsPrefixed() { $app = new Phalcon\Mvc\Micro(); $collection = new Phalcon\Mvc\Micro\Collection(); $collection->setPrefix('/personas'); $controller = new PersonasController(); $collection->setHandler($controller); $collection->map('/', 'index'); $collection->map('/edit/{number}', 'edit'); $app->mount($collection); $app->handle('/personas'); $this->assertEquals($controller->getEntered(), 1); $app->handle('/personas/edit/100'); $this->assertEquals($controller->getEntered(), 101); }
public static function getAppInstance() { if (!self::$appInstance) { try { /** * Read the configuration */ $config = (include APP_PATH . "/app/config/config.php"); /** * Read auto-loader */ include APP_PATH . "/app/config/loader.php"; /** * Read services */ $di = self::getDiInstance(); include APP_PATH . "/app/config/services.php"; /** * Handle the Route */ self::$appInstance = new \Phalcon\Mvc\Micro($di); $syncRoute = new Phalcon\Mvc\Micro\Collection(); // $syncRoute->setHandler(new SyncController($di)); $syncRoute->setHandler('SyncController', true); $syncRoute->setPrefix('sync/'); $syncRoute->map('get_user/{api}/{guid}', 'indexAction'); $syncRoute->map('add_user/{api}/{guid}', 'addUserAction'); $syncRoute->map('update_user/{api}/{guid}', 'updateUserAction'); $syncRoute->map('insert_user/{api}/{guid}', 'insertUserAction'); $syncRoute->map('plus_user/{api}/{guid}', 'plusUserAction'); self::$appInstance->mount($syncRoute); $asyncRoute = new Phalcon\Mvc\Micro\Collection(); // $asyncRoute->setHandler(new AsyncController($di)); $asyncRoute->setHandler('AsyncController', true); $asyncRoute->setPrefix('async/'); $asyncRoute->map('add_user/{api}/{guid}', 'addUserAction'); $asyncRoute->map('update_user/{api}/{guid}', 'updateUserAction'); $asyncRoute->map('insert_user/{api}/{guid}', 'insertUserAction'); $asyncRoute->map('plus_user/{api}/{guid}', 'plusUserAction'); self::$appInstance->mount($asyncRoute); file_put_contents("/tmp/sw_server_instance.log", "new AppInstance" . date("Y-m-d H:i:s") . "\r\n", FILE_APPEND); } catch (\Exception $e) { echo $e->getMessage() . '<br>'; echo '<pre>' . $e->getTraceAsString() . '</pre>'; } } return self::$appInstance; }
public static function getAppInstance() { if (!self::$appInstance) { try { /** * Read the configuration */ $config = (include APP_PATH . "/app/config/config.php"); /** * Read auto-loader */ include APP_PATH . "/app/config/loader.php"; /** * Read services */ $di = self::getDiInstance(); include APP_PATH . "/app/config/services.php"; self::$appInstance = new \Phalcon\Mvc\Micro($di); /** * Handle the Route, Sync RPC handler */ $syncRoute = new Phalcon\Mvc\Micro\Collection(); $syncRoute->setHandler('IndexController', true); $syncRoute->setPrefix('sync/'); $syncRoute->map('getUserById/{key}', 'getUserByIdAction'); $syncRoute->map('checkUserLoginInfo/{key}', 'checkUserLoginInfoAction'); $syncRoute->map('checkLoginName/{key}', 'checkLoginNameAction'); $syncRoute->map('addUser/{key}', 'addUserAction'); $syncRoute->map('updateUser/{key}', 'updateUserAction'); $syncRoute->map('deleteUser/{key}', 'deleteUserAction'); $syncRoute->map('getUsers/{key}', 'getUsersAction'); self::$appInstance->mount($syncRoute); /** * More, just like Async RPC handler */ } catch (\Exception $e) { echo $e->getMessage() . '<br>'; echo '<pre>' . $e->getTraceAsString() . '</pre>'; } } return self::$appInstance; }
<?php /** * Collections let us define groups of routes that will all use the same controller. * We can also set the handler to be lazy loaded. Collections can share a common prefix. * @var $productsOptionsCollection */ // This is an Immediately Invoked Function in php. The return value of the // anonymous function will be returned to any file that "includes" it. // e.g. $collection = include('products_options.php'); return call_user_func(function () { $productsOptionsCollection = new \Phalcon\Mvc\Micro\Collection(); $productsOptionsCollection->setPrefix('/' . $this->di->getConfig()->application->version . '/products_options')->setHandler('\\App\\Modules\\Backend\\Controllers\\ProductsOptionsController')->setLazy(true); // Set Access-Control-Allow headers. $productsOptionsCollection->options('/', 'optionsBase'); $productsOptionsCollection->options('/{id}', 'optionsOne'); // First paramter is the route, which with the collection prefix here would be GET /products_options/ // Second paramter is the function name of the Controller. $productsOptionsCollection->get('/', 'get'); // This is exactly the same execution as GET, but the Response has no body. $productsOptionsCollection->head('/', 'get'); // $id will be passed as a parameter to the Controller's specified function $productsOptionsCollection->get('/{id:' . $this->di->getConfig()->application->idRegExp . '+}', 'getOne'); $productsOptionsCollection->head('/{id:' . $this->di->getConfig()->application->idRegExp . '+}', 'getOne'); $productsOptionsCollection->post('/', 'post'); $productsOptionsCollection->post('/search', 'search'); $productsOptionsCollection->post('/search/{id:' . $this->di->getConfig()->application->idRegExp . '+}', 'searchOne'); $productsOptionsCollection->delete('/{id:' . $this->di->getConfig()->application->idRegExp . '+}', 'delete'); $productsOptionsCollection->put('/{id:' . $this->di->getConfig()->application->idRegExp . '+}', 'put'); $productsOptionsCollection->put('/upload/{id:' . $this->di->getConfig()->application->idRegExp . '+}', 'upload'); $productsOptionsCollection->put('/import', 'bulkImport');
<?php /** * Collections let us define groups of routes that will all use the same controller. * We can also set the handler to be lazy loaded. Collections can share a common prefix. * @var $autocompleteCollection */ // This is an Immeidately Invoked Function in php. The return value of the // anonymous function will be returned to any file that "includes" it. // e.g. $collection = include('autocomplete.php'); return call_user_func(function () { $userCollection = new \Phalcon\Mvc\Micro\Collection(); $userCollection->setPrefix('/v1/user')->setHandler('\\Api\\Controllers\\UserController')->setLazy(true); // Set Access-Control-Allow headers. $userCollection->options('/', 'optionsBase'); $userCollection->options('/{id,email,images}', 'optionsOne'); // First paramter is the route, which with the collection prefix here would be GET /autocomplete/ // Second paramter is the function name of the Controller. $userCollection->get('/', 'get'); $userCollection->post('/', 'post'); $userCollection->put('/{id:[a-zA-Z0-9_-]+}', 'put'); // This is exactly the same execution as GET, but the Response has no body. $userCollection->head('/', 'get'); return $userCollection; });
<?php /** * Collections let us define groups of routes that will all use the same controller. * We can also set the handler to be lazy loaded. Collections can share a common prefix. * @var $exampleCollection */ // This is an Immeidately Invoked Function in php. The return value of the // anonymous function will be returned to any file that "includes" it. // e.g. $collection = include('example.php'); return call_user_func(function () { $collection = new \Phalcon\Mvc\Micro\Collection(); $collection->setPrefix('/api/translation')->setHandler('\\Base\\Controllers\\Dictionary\\TranslationController')->setLazy(true); // Set Access-Control-Allow headers. $collection->options('/', 'optionsBase'); $collection->options('/{id}', 'optionsOne'); // First paramter is the route, which with the collection prefix here would be GET /example/ // Second paramter is the function name of the Controller. $collection->get('/', 'get'); // This is exactly the same execution as GET, but the Response has no body. $collection->head('/', 'get'); // $id will be passed as a parameter to the Controller's specified function $collection->get('/{id:[0-9]+}', 'getOne'); $collection->head('/{id:[0-9]+}', 'getOne'); $collection->post('/create', 'create'); $collection->post('/search', 'search'); $collection->post('/update', 'update'); $collection->delete('/{id:[0-9]+}', 'delete'); $collection->put('/{id:[0-9]+}', 'put'); $collection->patch('/{id:[0-9]+}', 'patch'); return $collection;
<?php /** * Collections let us define groups of routes that will all use the same controller. * We can also set the handler to be lazy loaded. Collections can share a common prefix. */ return call_user_func(function () { $exampleCollection = new \Phalcon\Mvc\Micro\Collection(); $exampleCollection->setPrefix('/v1/access_token')->setHandler('\\Phalcon2Rest\\Modules\\V1\\Controllers\\AccessTokenController')->setLazy(true); // Set Access-Control-Allow headers. $exampleCollection->options('/', 'optionsBase'); $exampleCollection->post('/', 'post'); return $exampleCollection; });
<?php /** * Standard routes for resource * Refer to routes/collections/example.php for further details */ return call_user_func(function () { $routes = new \Phalcon\Mvc\Micro\Collection(); // VERSION NUMBER SHOULD BE FIRST URL PARAMETER, ALWAYS // setHandler MUST be a string in order to support lazy loading $routes->setPrefix('/v1/programs')->setHandler('\\PhalconRest\\Controllers\\ProgramController')->setLazy(true); $routes->options('/', 'optionsBase'); $routes->options('/{id}', 'optionsOne'); $routes->get('/', 'get'); $routes->head('/', 'get'); $routes->post('/', 'post'); $routes->get('/{id:[0-9]+}', 'getOne'); $routes->head('/{id:[0-9]+}', 'getOne'); $routes->delete('/{id:[0-9]+}', 'delete'); $routes->put('/{id:[0-9]+}', 'put'); $routes->patch('/{id:[0-9]+}', 'patch'); return $routes; });
<?php /** * Collections let us define groups of routes that will all use the same controller. * We can also set the handler to be lazy loaded. Collections can share a common prefix. */ return call_user_func(function () { $exampleCollection = new \Phalcon\Mvc\Micro\Collection(); $exampleCollection->setPrefix('/v1/authorize')->setHandler('\\Phalcon2Rest\\Modules\\V1\\Controllers\\AuthorizeController')->setLazy(true); // Set Access-Control-Allow headers. $exampleCollection->options('/', 'optionsBase'); $exampleCollection->post('/', 'post'); return $exampleCollection; });
<?php /** * Collections let us define groups of routes that will all use the same controller. * We can also set the handler to be lazy loaded. Collections can share a common prefix. * * @link http://docs.phalconphp.com/en/latest/api/Phalcon_Mvc_Micro_Collection.html */ return call_user_func(function () { $testCollection = new \Phalcon\Mvc\Micro\Collection(); $testCollection->setPrefix('/' . VERSION . '/posts')->setHandler('Phanbook\\Controllers\\PostsController')->setLazy(true); // First paramter is the route, which with the collection prefix here would be GET /example/ // Second paramter is the function name of the Controller. $testCollection->get('/', 'index'); // This is exactly the same execution as GET, but the Response has no body. $testCollection->head('/', 'index'); // $id will be passed as a parameter to the Controller's specified function $testCollection->get('/{id:[0-9]+}', 'getOne'); $testCollection->head('/{id:[0-9]+}', 'getOne'); $testCollection->post('/', 'post'); $testCollection->delete('/{id:[0-9]+}', 'delete'); $testCollection->put('/{id:[0-9]+}', 'put'); $testCollection->patch('/{id:[0-9]+}', 'patch'); return $testCollection; });
<?php /** * Created by PhpStorm. * User: Dapo * Date: 09-Dec-14 * Time: 1:43 PM */ return call_user_func(function () { $api = new \Phalcon\Mvc\Micro\Collection(); $api->setPrefix('/v1/reports')->setHandler('\\PhalconRest\\Controllers\\ReportsController')->setLazy(true); $api->get('/summary', 'summary'); $api->get('/staff', 'staff'); $api->get('/details', 'details'); return $api; });
<?php /** * Collections let us define groups of routes that will all use the same controller. * We can also set the handler to be lazy loaded. Collections can share a common prefix. * @var $autocompleteCollection */ return call_user_func(function () { $collection = new \Phalcon\Mvc\Micro\Collection(); $collection->setPrefix('/v1/linkedinCallback')->setHandler('\\Api\\Controllers\\LinkedinCallbackController')->setLazy(true); // Set Access-Control-Allow headers. // $collection->options('/', 'optionsBase'); // $collection->options('/{access_token}', 'optionsOne'); // First paramter is the route, which with the collection prefix here would be GET /autocomplete/ // Second paramter is the function name of the Controller. $collection->get('/', 'get', 'login-linkedin-allow'); $collection->get('/{aacess}', 'get', 'login-linkedin-authenticating-allow'); // $collection->post('/', 'post'); // This is exactly the same execution as GET, but the Response has no body. // $collection->head('/', 'get'); return $collection; });
<?php /** * Collections let us define groups of routes that will all use the same controller. * We can also set the handler to be lazy loaded. Collections can share a common prefix. * @var $exampleCollection */ // This is an Immeidately Invoked Function in php. The return value of the // anonymous function will be returned to any file that "includes" it. // e.g. $collection = include('example.php'); return call_user_func(function () { $exampleCollection = new \Phalcon\Mvc\Micro\Collection(); $exampleCollection->setPrefix('/v1/example')->setHandler('\\PhalconRest\\Controllers\\ExampleController')->setLazy(true); // Set Access-Control-Allow headers. $exampleCollection->options('/', 'optionsBase'); $exampleCollection->options('/{id}', 'optionsOne'); // First paramter is the route, which with the collection prefix here would be GET /example/ // Second paramter is the function name of the Controller. $exampleCollection->get('/', 'get'); // This is exactly the same execution as GET, but the Response has no body. $exampleCollection->head('/', 'get'); // $id will be passed as a parameter to the Controller's specified function $exampleCollection->get('/{id:[0-9]+}', 'getOne'); $exampleCollection->head('/{id:[0-9]+}', 'getOne'); $exampleCollection->post('/', 'post'); $exampleCollection->delete('/{id:[0-9]+}', 'delete'); $exampleCollection->put('/{id:[0-9]+}', 'put'); $exampleCollection->patch('/{id:[0-9]+}', 'patch'); return $exampleCollection; });
<?php /** * Standard routes for resource * Refer to routes/collections/example.php for further details */ return call_user_func(function () { $routes = new \Phalcon\Mvc\Micro\Collection(); // VERSION NUMBER SHOULD BE FIRST URL PARAMETER, ALWAYS // setHandler MUST be a string in order to support lazy loading $routes->setPrefix('/v1/cabins')->setHandler('\\PhalconRest\\Controllers\\CabinController')->setLazy(true); $routes->options('/', 'optionsBase'); $routes->options('/{id}', 'optionsOne'); $routes->get('/', 'get'); $routes->head('/', 'get'); $routes->post('/', 'post'); $routes->get('/{id:[0-9]+}', 'getOne'); $routes->head('/{id:[0-9]+}', 'getOne'); $routes->delete('/{id:[0-9]+}', 'delete'); $routes->put('/{id:[0-9]+}', 'put'); $routes->patch('/{id:[0-9]+}', 'patch'); return $routes; });
<?php /** * Standard routes for resource * Refer to routes/collections/example.php for further details */ return call_user_func(function () { $routes = new \Phalcon\Mvc\Micro\Collection(); // VERSION NUMBER SHOULD BE FIRST URL PARAMETER, ALWAYS // setHandler MUST be a string in order to support lazy loading $routes->setPrefix('/v1/requests')->setHandler('\\PhalconRest\\Controllers\\RequestController')->setLazy(true); $routes->options('/', 'optionsBase'); $routes->options('/{id}', 'optionsOne'); $routes->get('/', 'get'); $routes->head('/', 'get'); $routes->post('/', 'post'); $routes->get('/{id:[0-9]+}', 'getOne'); $routes->head('/{id:[0-9]+}', 'getOne'); $routes->delete('/{id:[0-9]+}', 'delete'); $routes->put('/{id:[0-9]+}', 'put'); $routes->patch('/{id:[0-9]+}', 'patch'); return $routes; });
<?php /** * Collections let us define groups of routes that will all use the same controller. * We can also set the handler to be lazy loaded. Collections can share a common prefix. * @var $exampleCollection */ // This is an Immeidately Invoked Function in php. The return value of the // anonymous function will be returned to any file that "includes" it. // e.g. $collection = include('example.php'); return call_user_func(function () { $collection = new \Phalcon\Mvc\Micro\Collection(); $collection->setPrefix('/api/resource')->setHandler('\\Base\\Controllers\\Resources\\ResourceController')->setLazy(true); // Set Access-Control-Allow headers. $collection->options('/', 'optionsBase'); $collection->options('/{id}', 'optionsOne'); // First paramter is the route, which with the collection prefix here would be GET /example/ // Second paramter is the function name of the Controller. $collection->get('/', 'get'); // This is exactly the same execution as GET, but the Response has no body. $collection->head('/', 'get'); // $id will be passed as a parameter to the Controller's specified function $collection->get('/{id:[0-9]+}', 'getOne'); $collection->head('/{id:[0-9]+}', 'getOne'); $collection->post('/create', 'create'); $collection->post('/update', 'update'); $collection->delete('/{id:[0-9]+}', 'delete'); $collection->put('/{id:[0-9]+}', 'put'); $collection->patch('/{id:[0-9]+}', 'patch'); return $collection; });
<?php /** * Created by PhpStorm. * User: Dapo * Date: 09-Dec-14 * Time: 1:43 PM */ return call_user_func(function () { $api = new \Phalcon\Mvc\Micro\Collection(); $api->setPrefix('/v1/grouper')->setHandler('\\PhalconRest\\Controllers\\GrouperController')->setLazy(true); // Issues Handlers $api->get('/issues', 'issues'); $api->options('/issues', 'info'); $api->get('/issues/principles', 'issuePrinciples'); $api->options('/issues/principles', 'info'); $api->get('/issues/stats', 'issueStats'); $api->options('/issues/stats', 'info'); $api->put('/principles/{id:[0-9]+}', 'updatePrinciple'); $api->options('/principles/{id:[0-9]+}', 'info'); $api->get('/reviews', 'reviews'); $api->options('/reviews', 'info'); $api->post('/reviews', 'newReview'); $api->put('/reviews/{id:[0-9]+}', 'updateReview'); return $api; });
<?php /** * Standard routes for resource * Refer to routes/collections/example.php for further details */ return call_user_func(function () { $routes = new \Phalcon\Mvc\Micro\Collection(); // VERSION NUMBER SHOULD BE FIRST URL PARAMETER, ALWAYS // setHandler MUST be a string in order to support lazy loading $routes->setPrefix('/v1/employees')->setHandler('\\PhalconRest\\Controllers\\EmployeeController')->setLazy(true); $routes->options('/', 'optionsBase'); $routes->options('/{id}', 'optionsOne'); $routes->get('/', 'get'); $routes->head('/', 'get'); $routes->post('/', 'post'); $routes->get('/{id:[0-9]+}', 'getOne'); $routes->head('/{id:[0-9]+}', 'getOne'); $routes->delete('/{id:[0-9]+}', 'delete'); $routes->put('/{id:[0-9]+}', 'put'); $routes->patch('/{id:[0-9]+}', 'patch'); return $routes; });
<?php /** * Collections let us define groups of routes that will all use the same controller. * We can also set the handler to be lazy loaded. Collections can share a common prefix. * @var $autocompleteCollection */ return call_user_func(function () { $collection = new \Phalcon\Mvc\Micro\Collection(); $collection->setPrefix('/v1/skill')->setHandler('\\Api\\Controllers\\SkillController')->setLazy(true); // Set Access-Control-Allow headers. $collection->options('/', 'optionsBase'); // $collection->options('/{access_token}', 'optionsOne'); // First paramter is the route, which with the collection prefix here would be GET /autocomplete/ // Second paramter is the function name of the Controller. $collection->get('/', 'get', 'skill-authbasic'); // $collection->post('/', 'post'); // $collection->put('/', 'put'); // This is exactly the same execution as GET, but the Response has no body. // $collection->head('/', 'get'); return $collection; });
<?php /** * Collections let us define groups of routes that will all use the same controller. * We can also set the handler to be lazy loaded. Collections can share a common prefix. * @var $adminGroupsCollection */ // This is an Immediately Invoked Function in php. The return value of the // anonymous function will be returned to any file that "includes" it. // e.g. $collection = include('admin_groups.php'); return call_user_func(function () { $adminGroupsCollection = new \Phalcon\Mvc\Micro\Collection(); $adminGroupsCollection->setPrefix('/' . $this->di->getConfig()->application->version . '/admin/groups')->setHandler('\\App\\Modules\\Admin\\Controllers\\GroupsController')->setLazy(true); // Set Access-Control-Allow headers. $adminGroupsCollection->options('/', 'optionsBase'); $adminGroupsCollection->options('/{id}', 'optionsOne'); // First paramter is the route, which with the collection prefix here would be GET /groups/ // Second paramter is the function name of the Controller. $adminGroupsCollection->get('/', 'get'); // This is exactly the same execution as GET, but the Response has no body. $adminGroupsCollection->head('/', 'get'); $adminGroupsCollection->post('/search', 'search'); $adminGroupsCollection->post('/search/{id:' . $this->di->getConfig()->application->idRegExp . '+}', 'searchOne'); // $id will be passed as a parameter to the Controller's specified function $adminGroupsCollection->get('/{id:' . $this->di->getConfig()->application->idRegExp . '+}', 'getOne'); $adminGroupsCollection->head('/{id:' . $this->di->getConfig()->application->idRegExp . '+}', 'getOne'); $adminGroupsCollection->post('/', 'post'); $adminGroupsCollection->delete('/{id:' . $this->di->getConfig()->application->idRegExp . '+}', 'delete'); $adminGroupsCollection->put('/{id:' . $this->di->getConfig()->application->idRegExp . '+}', 'put'); return $adminGroupsCollection; });
<?php /** * Standard routes for resource * Refer to routes/collections/example.php for further details */ return call_user_func(function () { $routes = new \Phalcon\Mvc\Micro\Collection(); // VERSION NUMBER SHOULD BE FIRST URL PARAMETER, ALWAYS // setHandler MUST be a string in order to support lazy loading $routes->setPrefix('/v1/events')->setHandler('\\PhalconRest\\Controllers\\EventController')->setLazy(true); $routes->options('/', 'optionsBase'); $routes->options('/{id}', 'optionsOne'); $routes->get('/', 'get'); $routes->head('/', 'get'); $routes->post('/', 'post'); $routes->get('/{id:[0-9]+}', 'getOne'); $routes->head('/{id:[0-9]+}', 'getOne'); $routes->delete('/{id:[0-9]+}', 'delete'); $routes->put('/{id:[0-9]+}', 'put'); $routes->patch('/{id:[0-9]+}', 'patch'); return $routes; });
<?php /** * Created by PhpStorm. * User: Dapo * Date: 09-Dec-14 * Time: 1:43 PM */ return call_user_func(function () { $api = new \Phalcon\Mvc\Micro\Collection(); $api->setPrefix('/v1')->setHandler('\\PhalconRest\\Controllers\\AppController')->setLazy(true); $api->get('/legalHeads', 'getLegalHeads'); $api->post('/setStandard', 'setAsStandard'); $api->post('/updateSubjectMatter', 'updateSubjectMatter'); $api->post('/changeLegalHead', 'changeLegalHead'); $api->post('/changeSubjectMatter', 'changeSubjectMatter'); $api->post('/updateIssue', 'updateIssue'); $api->post('/mergeSubjectMatters', 'mergeSubjectMatters'); $api->post('/mergeIssues', 'mergeIssues'); $api->post('/detachRatio', 'detachRatio'); $api->post('/markDone', 'markDone'); $api->post('/removeStandard', 'removeStandard'); $api->post('/newBookCase/{id:[0-9]+}', 'newBookCase'); $api->get('/bookCases/{id:[0-9]+}', 'getCases'); $api->get('/alternateCitations/{id:[0-9]+}', 'getCaseAlternateCitations'); $api->get('/fullCases', 'fullCases'); $api->get('/fullCases/{id:[0-9]+}/{term}', 'fullCases'); $api->get('/fullCases/{id:[0-9]+}/{term}/{type}', 'fullCases'); $api->get('/caseList/{term}', 'caseList'); $api->delete('/deleteCase/{id:[0-9]+}', 'deleteCase'); return $api;
<?php /** * Standard routes for resource * Refer to routes/collections/example.php for further details */ return call_user_func(function () { $routes = new \Phalcon\Mvc\Micro\Collection(); // VERSION NUMBER SHOULD BE FIRST URL PARAMETER, ALWAYS // setHandler MUST be a string in order to support lazy loading $routes->setPrefix('/v1/owners')->setHandler('\\PhalconRest\\Controllers\\OwnerController')->setLazy(true); $routes->options('/', 'optionsBase'); $routes->options('/{id}', 'optionsOne'); $routes->get('/', 'get'); $routes->head('/', 'get'); $routes->post('/', 'post'); $routes->get('/{id:[0-9]+}', 'getOne'); $routes->head('/{id:[0-9]+}', 'getOne'); $routes->delete('/{id:[0-9]+}', 'delete'); $routes->put('/{id:[0-9]+}', 'put'); $routes->patch('/{id:[0-9]+}', 'patch'); return $routes; });
<?php /** * Standard routes for resource * Refer to routes/collections/example.php for further details */ return call_user_func(function () { $routes = new \Phalcon\Mvc\Micro\Collection(); // VERSION NUMBER SHOULD BE FIRST URL PARAMETER, ALWAYS // setHandler MUST be a string in order to support lazy loading $routes->setPrefix('/v1/sessions')->setHandler('\\PhalconRest\\Controllers\\SessionController')->setLazy(true); $routes->options('/', 'optionsBase'); $routes->options('/{id}', 'optionsOne'); $routes->get('/', 'get'); $routes->head('/', 'get'); $routes->post('/', 'post'); $routes->get('/{id:[0-9]+}', 'getOne'); $routes->head('/{id:[0-9]+}', 'getOne'); $routes->delete('/{id:[0-9]+}', 'delete'); $routes->put('/{id:[0-9]+}', 'put'); $routes->patch('/{id:[0-9]+}', 'patch'); return $routes; });
<?php /** * Define all routes to be used in module * * @package Reddit_API * @subpackage Post_Routes_Collections * @author Enrique Ojeda <*****@*****.**> */ return call_user_func(function () { /** * Instance collection from Phalcon Mvc */ $collection = new \Phalcon\Mvc\Micro\Collection(); /** * Define handler (Controller) */ $handler = '\\Modules\\Post\\Controllers\\PostController'; /** * Set prefix, handler and async process as true. */ $collection->setPrefix('')->setHandler($handler)->setLazy(true); /** * Define urls (Routes) and link them with controller */ $collection->post('/post/submit', 'submit'); $collection->get('/posts/{page:[0-9]+}', 'fetch'); $collection->get('/posts', 'fetch'); $collection->post('/post/vote', 'vote'); return $collection; });
<?php /** * Collections let us define groups of routes that will all use the same controller. * We can also set the handler to be lazy loaded. Collections can share a common prefix. * @var $channelsCollection */ // This is an Immediately Invoked Function in php. The return value of the // anonymous function will be returned to any file that "includes" it. // e.g. $collection = include('channels.php'); return call_user_func(function () { $channelsCollection = new \Phalcon\Mvc\Micro\Collection(); $channelsCollection->setPrefix('/' . $this->di->getConfig()->application->version . '/channels')->setHandler('\\App\\Modules\\Backend\\Controllers\\ChannelsController')->setLazy(true); // Set Access-Control-Allow headers. $channelsCollection->options('/', 'optionsBase'); $channelsCollection->options('/{id}', 'optionsOne'); // First paramter is the route, which with the collection prefix here would be GET /channels/ // Second paramter is the function name of the Controller. $channelsCollection->get('/', 'get'); // This is exactly the same execution as GET, but the Response has no body. $channelsCollection->head('/', 'get'); $channelsCollection->post('/search', 'search'); $channelsCollection->post('/search/{id:' . $this->di->getConfig()->application->idRegExp . '+}', 'searchOne'); // $id will be passed as a parameter to the Controller's specified function $channelsCollection->get('/{id:' . $this->di->getConfig()->application->idRegExp . '+}', 'getOne'); $channelsCollection->head('/{id:' . $this->di->getConfig()->application->idRegExp . '+}', 'getOne'); $channelsCollection->post('/', 'post'); $channelsCollection->delete('/{id:' . $this->di->getConfig()->application->idRegExp . '+}', 'delete'); $channelsCollection->put('/{id:' . $this->di->getConfig()->application->idRegExp . '+}', 'put'); return $channelsCollection; });
<?php /** * Collections let us define groups of routes that will all use the same controller. * We can also set the handler to be lazy loaded. Collections can share a common prefix. * @var $autocompleteCollection */ return call_user_func(function () { $collection = new \Phalcon\Mvc\Micro\Collection(); $collection->setPrefix('/v1/registerPersonal')->setHandler('\\Api\\Controllers\\RegisterPersonalController')->setLazy(true); // Set Access-Control-Allow headers. $collection->options('/', 'optionsBase'); // $collection->options('/{access_token}', 'optionsOne'); // First paramter is the route, which with the collection prefix here would be GET /autocomplete/ // Second paramter is the function name of the Controller. $collection->get('/', 'get', 'registerPersonal-authbasic'); // $collection->get('/{aacess}', 'get', 'registerPersonal-authbasic'); $collection->post('/', 'post'); $collection->put('/', 'put'); // This is exactly the same execution as GET, but the Response has no body. $collection->head('/', 'get'); return $collection; });
<?php /** * Collections let us define groups of routes that will all use the same controller. * We can also set the handler to be lazy loaded. Collections can share a common prefix. * @var $exampleCollection */ // This is an Immeidately Invoked Function in php. The return value of the // anonymous function will be returned to any file that "includes" it. // e.g. $collection = include('example.php'); return call_user_func(function () { $collection = new \Phalcon\Mvc\Micro\Collection(); $collection->setPrefix('/api/wordType')->setHandler('\\Base\\Controllers\\Dictionary\\WordTypeController')->setLazy(true); // Set Access-Control-Allow headers. $collection->options('/', 'optionsBase'); $collection->options('/{id}', 'optionsOne'); // First paramter is the route, which with the collection prefix here would be GET /example/ // Second paramter is the function name of the Controller. $collection->get('/', 'get'); // This is exactly the same execution as GET, but the Response has no body. $collection->head('/', 'get'); // $id will be passed as a parameter to the Controller's specified function $collection->get('/{id:[0-9]+}', 'getOne'); $collection->head('/{id:[0-9]+}', 'getOne'); $collection->post('/create', 'create'); $collection->post('/search', 'search'); $collection->post('/update', 'update'); $collection->delete('/{id:[0-9]+}', 'delete'); $collection->put('/{id:[0-9]+}', 'put'); $collection->patch('/{id:[0-9]+}', 'patch'); return $collection;
<?php /** * Created by PhpStorm. * User: Dapo * Date: 08-Dec-14 * Time: 9:48 AM */ return call_user_func(function () { $userCollection = new \Phalcon\Mvc\Micro\Collection(); $userCollection->setPrefix('/v1/users')->setHandler('\\PhalconRest\\Controllers\\UserController')->setLazy(true); $userCollection->get('/', 'index'); $userCollection->post('/login', 'login'); $userCollection->post('/login_jwt', 'login_jwt'); $userCollection->options('/login_jwt', 'info'); $userCollection->post('/register', 'register'); return $userCollection; });