コード例 #1
0
ファイル: ApiRoutes.php プロジェクト: bullhorn/fast-rest
 public function addRoutes(Router $router)
 {
     $router->add('/' . $this->getApiRootUrl() . '(\\/?)', array('namespace' => $this->getApiControllerRootNamespace(), 'controller' => 'Index', 'action' => 'index'));
     $router->addGet('/' . $this->getApiRootUrl() . '/:controller/:params', array('namespace' => $this->getApiControllerRootNamespace(), 'controller' => 1, 'action' => 'show', 'params' => 2));
     $router->addGet('/' . $this->getApiRootUrl() . '/:controller', array('namespace' => $this->getApiControllerRootNamespace(), 'controller' => 1, 'action' => 'index'));
     $router->addPost('/' . $this->getApiRootUrl() . '/:controller', array('namespace' => $this->getApiControllerRootNamespace(), 'controller' => 1, 'action' => 'create'));
     $router->addOptions('/' . $this->getApiRootUrl() . '/:controller', array('namespace' => $this->getApiControllerRootNamespace(), 'controller' => 1, 'action' => 'options'));
     $router->addOptions('/' . $this->getApiRootUrl() . '/:controller/:params', array('namespace' => $this->getApiControllerRootNamespace(), 'controller' => 1, 'action' => 'options'));
     $router->addDelete('/' . $this->getApiRootUrl() . '/:controller/:params', array('namespace' => $this->getApiControllerRootNamespace(), 'controller' => 1, 'action' => 'delete', 'params' => 2));
     $router->addPut('/' . $this->getApiRootUrl() . '/:controller/:params', array('namespace' => $this->getApiControllerRootNamespace(), 'controller' => 1, 'action' => 'update', 'params' => 2));
 }
コード例 #2
0
ファイル: routes.php プロジェクト: byhbt/napthe-baokim
<?php

use Phalcon\Mvc\Router;
$router = new Router(false);
$router->removeExtraSlashes(true);
$router->addGet("/", ['controller' => 'index', 'action' => 'index']);
$router->addPost("/", ['controller' => 'index', 'action' => 'handleCardSubmit']);
$router->addGet('/index/success', ['controller' => 'index', 'action' => 'success']);
return $router;
コード例 #3
0
<?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;
コード例 #4
0
ファイル: routes.php プロジェクト: nutrimax1987/phalcon-php
<?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 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"));
//Create a new element. Ex: /user
$router->addPost('/:controller', array('controller' => 1, 'action' => "create"));
//Update a new element. Ex: /user
$router->addPut('/:controller/:int', array('controller' => 1, 'action' => "update", 'id' => 2));
//DELETE a new element. Ex: /user
$router->addDelete('/:controller/:int', array('controller' => 'user', 'action' => "delete", 'id' => 2));
$router->add('/:controller/index', array('controller' => 1, 'action' => "index"));
// CRUD and Session
$router->add('/:controller/signup', array('controller' => 1, 'action' => "signup"));
$router->add('/:controller/login', array('controller' => 1, 'action' => "login"));
$router->add('/:controller/logout', array('controller' => 1, 'action' => "logout"));
//CRUD
$router->add('/:controller/search/:int', array('controller' => 1, 'action' => "search"));
$router->add('/:controller/edit/:int', array('controller' => 1, 'action' => "edit", 'id' => '2'));
//not founded route
$router->notFound(array('controller' => 'error', 'action' => 'page404'));
$router->setDefaults(array('controller' => 'index', 'action' => 'index'));
return $router;
コード例 #5
0
ファイル: routes.php プロジェクト: carriercomm/Phaste
<?php

use Phalcon\Mvc\Router;
$router = new Router();
$router->addGet("/", array("controller" => "index"));
$router->addPost("/new", array("controller" => "new"));
// Covers /v/ and /view/
$router->addGet("/v(iew)?/([a-zA-Z0-9]{5,13})", array("controller" => "view", "id" => 2));
$router->addGet("/v(iew)?/([a-zA-Z0-9]{5,13})/raw", array("controller" => "view", "action" => "raw", "id" => 2));
$router->removeExtraSlashes(true);
return $router;
コード例 #6
0
ファイル: routes.php プロジェクト: danzabar/phalcon-starter
<?php

use Phalcon\Mvc\Router;
$router = new Router(false);
/**
 *  You can define routes in this file the router gets 
 *  loaded back into the dependency injection after you define routes.
 *
 *
 */
$router->addGet('/', 'Home::show');
$router->addGet('/response', 'Home::response');
return $router;
コード例 #7
0
ファイル: bootstrap.php プロジェクト: antsand/builtwith
/**
 * Start the session the first time some component request the session service
 */
$di->set('session', function () {
    $session = new SessionAdapter();
    $session->start();
    return $session;
});
/**
 * Register configurations
 */
$di->set('config', function () use($config) {
    return $config;
});
/**
 * Register router
 */
$di->set('router', function () {
    $router = new Router();
    $router->removeExtraSlashes(true);
    $router->setDefaults(['controller' => 'index', 'action' => 'index']);
    /*$router->notFound([
          'controller'    => 'errors',
          'action'        => 'pageNotFound'
      ]);*/
    $router->addGet('/project/{profile:([a-zA-Z0-9-(.)]+)}', ['action' => 'profile', 'project' => 1]);
    $router->addPost('/filter', ['action' => 'filter'])->beforeMatch(function ($uri, $route) {
        return isset($_SERVER['HTTP_X_REQUESTED_WITH']) && $_SERVER['HTTP_X_REQUESTED_WITH'] == 'XMLHttpRequest';
    });
    return $router;
});
コード例 #8
0
ファイル: Router.php プロジェクト: mattvb91/cphalcon
 public function addGet($pattern, $paths = null, $position = Router::POSITION_LAST)
 {
     return parent::addGet($pattern, $paths, $position);
 }