当前位置: 首页>>代码示例>>PHP>>正文


PHP Router::setDefaults方法代码示例

本文整理汇总了PHP中Phalcon\Mvc\Router::setDefaults方法的典型用法代码示例。如果您正苦于以下问题:PHP Router::setDefaults方法的具体用法?PHP Router::setDefaults怎么用?PHP Router::setDefaults使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Phalcon\Mvc\Router的用法示例。


在下文中一共展示了Router::setDefaults方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: Router

<?php

use Phalcon\Mvc\Router;
$router = new Router();
//Remove trailing slashes automatically
$router->removeExtraSlashes(true);
//main route
$router->add("/", array('controller' => 'index', 'action' => 'index'));
//GET VERB - GET ELEMENT
//Get elemets of relationship. Ex: /department/2/user
$router->addGet('/:controller/:int/([a-zA-Z0-9_-]+)', array('controller' => 1, 'action' => "list", 'id' => 2, 'relationship' => 3));
//Get one element. Ex: /user/2
$router->addGet('/:controller/:int', array('controller' => 1, 'action' => "get", 'id' => 2));
//Get all elements. Ex: /user
$router->addGet('/:controller', array('controller' => 1, 'action' => "list"));
//POST VERB - CREATE ELEMENT
//Create a new element. Ex: /user
$router->addPost('/:controller', array('controller' => 1, 'action' => "save"));
//PUT VERB - UPDATE ELEMENT
//Update a new element. Ex: /user
$router->addPut('/:controller/:int', array('controller' => 1, 'action' => "save", 'id' => 2));
//DELETE VERB - UPDATE ELEMENT
//Update a new element. Ex: /user
$router->addDelete('/:controller/:int', array('controller' => 1, 'action' => "delete", 'id' => 2));
//not founded route
$router->notFound(array('controller' => 'error', 'action' => 'page404'));
$router->setDefaults(array('controller' => 'index', 'action' => 'index'));
return $router;
开发者ID:GeraldoSilva,项目名称:API-REST-PHALCON-PHP,代码行数:28,代码来源:routes.php

示例2: Router

/**
 * Phanbook : Delightfully simple forum software
 *
 * Licensed under The GNU License
 * For full copyright and license information, please see the LICENSE.txt
 * Redistributions of files must retain the above copyright notice.
 *
 * @link    http://phanbook.com Phanbook Project
 * @since   1.0.0
 * @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt
 */
use Phalcon\Mvc\Router\Group;
use Phalcon\Mvc\Router;
$router = new Router(false);
$router->setDefaults(['module' => 'frontend', 'controller' => 'posts', 'action' => 'index']);
$router->removeExtraSlashes(true);
/*
 * All defined routes are traversed in reverse order until Phalcon\Mvc\Router
 * finds the one that matches the given URI and processes it, while ignoring the rest.
 */
$frontend = new Group(['module' => 'frontend']);
$frontend->add('/:controller/:action/:params', ['controller' => 1, 'action' => 2, 'params' => 3]);
$frontend->add('/:controller/:int', ['controller' => 1, 'id' => 2]);
$frontend->add('/:controller/:int/{slug:[a-z\\-]+}', ['controller' => 1, 'id' => 2, 'slug' => 3, 'action' => 'view']);
$frontend->add('/posts/:int/{slug:[a-z\\-]+}', ['id' => 1, 'slug' => 2, 'action' => 'view']);
$frontend->add('/:controller[/]?', ['controller' => 1]);
$frontend->add('/blog/{id:[0-9]+}/{slug:[a-z\\-]+}', ['controller' => 'posts', 'action' => 'view']);
$frontend->add('/questions/{id:[0-9]+}/{slug:[a-z\\-]+}', ['controller' => 'posts', 'action' => 'view']);
$frontend->add('/questions/new', ['controller' => 'posts', 'action' => 'new']);
$frontend->add('/');
开发者ID:phanbook,项目名称:openshift,代码行数:30,代码来源:routes.php

示例3: Router

<?php

use Phalcon\Mvc\Router;
$router = new Router();
//路由
$router->add('/', array('namespace' => 'Index\\Controllers', 'controller' => 'Index', 'action' => 'index'));
$router->add('/(index|Index)/:controller/:action/:params', array('namespace' => 'Index\\Controllers', 'controller' => 2, 'action' => 3, 'params' => 4));
$router->add('/(App|app)/:controller/:action/:params', array('namespace' => 'App\\Controllers', 'controller' => 2, 'action' => 3, 'params' => 4));
$router->add('/(Agent|agent)/:controller/:action/:params', array('namespace' => 'Agent\\Controllers', 'controller' => 2, 'action' => 3, 'params' => 4));
$router->notFound(array("namespace" => 'System\\Controllers', "controller" => "Error", "action" => "error404"));
$router->setDefaults(array('namespace' => 'Index\\Controllers', 'controller' => 'Index', 'action' => 'index'));
return $router;
开发者ID:chenshuhao,项目名称:BeginShake,代码行数:12,代码来源:Route.php

示例4: Router

<?php

use Phalcon\Mvc\Router\Group;
use Phalcon\Mvc\Router;
$router = new Router(false);
$router->setDefaults(['controller' => 'tests', 'action' => 'index']);
$router->removeExtraSlashes(true);
$prefix = '/' . VERSION . '/';
//tests
$tests = new Group(['controller' => 'tests']);
$tests->setPrefix($prefix . 'tests');
$tests->addGet('', ['action' => 'index']);
$tests->addGet('/{id:[0-9]+}', ['action' => 'view']);
$tests->addPost('/new', ['action' => 'new']);
$tests->addPut('/{id:[0-9]+}', ['action' => 'update']);
//task
$tasks = new Group(['controller' => 'task']);
$tasks->setPrefix($prefix . 'tasks');
$tasks->addGet('', ['action' => 'index']);
$tasks->addGet('/{id:[0-9]+}', ['action' => 'view']);
$tasks->addPost('/new', ['action' => 'new']);
$tasks->addPut('/{id:[0-9]+}', ['action' => 'update']);
//token
$token = new Group(['controller' => 'token']);
$token->setPrefix($prefix . 'token');
$token->add('', ['action' => 'index']);
//mount
$router->mount($token);
$router->mount($tests);
$router->mount($tasks);
return $router;
开发者ID:duythien,项目名称:phalcon-api,代码行数:31,代码来源:routes.php

示例5: setDefaults

 public function setDefaults(array $defaults)
 {
     return parent::setDefaults($defaults);
 }
开发者ID:mattvb91,项目名称:cphalcon,代码行数:4,代码来源:Router.php


注:本文中的Phalcon\Mvc\Router::setDefaults方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。