當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Router::setDefaultNamespace方法代碼示例

本文整理匯總了PHP中Phalcon\Mvc\Router::setDefaultNamespace方法的典型用法代碼示例。如果您正苦於以下問題:PHP Router::setDefaultNamespace方法的具體用法?PHP Router::setDefaultNamespace怎麽用?PHP Router::setDefaultNamespace使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Phalcon\Mvc\Router的用法示例。


在下文中一共展示了Router::setDefaultNamespace方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: Router

<?php

use Phalcon\Mvc\Router;
// Create the router
$router = new Router();
$router->setDefaultNamespace('App\\Controllers');
$router->removeExtraSlashes(true);
$router->add("/", array('namespace' => 'App\\Controllers', "controller" => "index", "action" => "index"))->setName('home');
$router->add('/api/(v1|v2)/about', array('namespace' => 'App\\Controllers\\api\\v1', 'controller' => 'about', 'version' => 1))->setName('about');
$router->notFound(array("controller" => "index", "action" => "route404"));
$router->handle();
開發者ID:kenikori,項目名稱:phalcon2_invo,代碼行數:11,代碼來源:routes.php

示例2: FactoryDefault

 */
use Phalcon\Mvc\Router;
use Phalcon\Mvc\Url as UrlResolver;
use Phalcon\DI\FactoryDefault;
use Phalcon\Session\Adapter\Files as SessionAdapter;
/**
 * The FactoryDefault Dependency Injector automatically register the right services providing a full stack framework
 */
$di = new FactoryDefault();
/**
 * Registering a router
 */
$di['router'] = function () {
    $router = new Router();
    $router->setDefaultModule("frontend");
    $router->setDefaultNamespace("Phalconapp\\Frontend\\Controllers");
    return $router;
};
/**
 * The URL component is used to generate all kind of urls in the application
 */
$di['url'] = function () {
    $url = new UrlResolver();
    $url->setBaseUri('/phalconapp/');
    return $url;
};
/**
 * Start the session the first time some component request the session service
 */
$di['session'] = function () {
    $session = new SessionAdapter();
開發者ID:keita-nishimoto,項目名稱:phalconapp,代碼行數:31,代碼來源:services.php

示例3: FactoryDefault

use Phalcon\Session\Adapter\Files as SessionAdapter;
use Phalcon\Mvc\Model\Metadata\Memory as MetaDataAdapter;
use Phalcon\Mvc\View;
use Phalcon\Mvc\View\Engine\Volt as VoltEngine;
use Phalcon\Loader;
/**
 * The FactoryDefault Dependency Injector automatically registers the right services to provide a full stack framework
 */
$di = new FactoryDefault();
/**
 * Registering a router
 */
$di->setShared('router', function () {
    $router = new Router(false);
    $router->setDefaultModule('frontend');
    $router->setDefaultNamespace('Multimodule\\Frontend\\Controllers');
    return $router;
});
/**
 * The URL component is used to generate all kinds of URLs in the application
 */
$di->setShared('url', function () use($config) {
    $url = new UrlResolver();
    $url->setBaseUri($config->application->baseUri);
    return $url;
});
/**
 * Setting up the view component
 */
$di->setShared('view', function () use($config) {
    $view = new View();
開發者ID:nhannv56,項目名稱:MultiModule,代碼行數:31,代碼來源:services.php

示例4: setDefaultNamespace

 public function setDefaultNamespace($namespaceName)
 {
     return parent::setDefaultNamespace($namespaceName);
 }
開發者ID:mattvb91,項目名稱:cphalcon,代碼行數:4,代碼來源:Router.php

示例5: FactoryDefault

 */
use Phalcon\Mvc\Router;
use Phalcon\Mvc\Url as UrlResolver;
use Phalcon\DI\FactoryDefault;
use Phalcon\Session\Adapter\Files as SessionAdapter;
/**
 * The FactoryDefault Dependency Injector automatically register the right services providing a full stack framework
 */
$di = new FactoryDefault();
/**
 * Registering a router
 */
$di['router'] = function () {
    $router = new Router();
    $router->setDefaultModule("frontend");
    $router->setDefaultNamespace("Modules\\Modules\\Frontend\\Controllers");
    $router->setUriSource(\Phalcon\Mvc\Router::URI_SOURCE_SERVER_REQUEST_URI);
    $router->removeExtraSlashes(TRUE);
    return $router;
};
/**
 * The URL component is used to generate all kind of urls in the application
 */
$di['url'] = function () {
    $url = new UrlResolver();
    $url->setBaseUri('/');
    return $url;
};
/**
 * Start the session the first time some component request the session service
 */
開發者ID:boiler256,項目名稱:mvc,代碼行數:31,代碼來源:services.php

示例6: FactoryDefault

use Phalcon\Di\FactoryDefault;
use Phalcon\Session\Adapter\Files as SessionAdapter;
use Phalcon\Mvc\Model\Metadata\Memory as MetaDataAdapter;
use Phalcon\Mvc\View;
use Phalcon\Mvc\View\Engine\Volt as VoltEngine;
/**
 * The FactoryDefault Dependency Injector automatically registers the right services to provide a full stack framework
 */
$di = new FactoryDefault();
/**
 * Registering a router
 */
$di->setShared('router', function () {
    $router = new Router();
    $router->setDefaultModule('core');
    $router->setDefaultNamespace('Phlame\\Core\\Controllers');
    return $router;
});
/**
 * The URL component is used to generate all kinds of URLs in the application
 */
$di->setShared('url', function () use($config) {
    $url = new UrlResolver();
    $url->setBaseUri($config->application->baseUri);
    return $url;
});
/**
 * Setting up the view component
 */
//$di->setShared('view', function () use ($config) {
//$view = new View();
開發者ID:Oscailte,項目名稱:phlame,代碼行數:31,代碼來源:services.php

示例7: function

 */
$di->set("config", function () use($config) {
    return $config;
});
/**
 * Registering a router
 */
$di->setShared('router', function () use($config) {
    $router = new Router();
    //var_dump($config->application->modules);die();
    /**
     * Include routes
     */
    require __DIR__ . '/../config/routes.php';
    $router->setDefaultModule('cliente');
    $router->setDefaultNamespace('Ticobox\\Cliente\\Controllers');
    return $router;
});
/**
 * The URL component is used to generate all kinds of URLs in the application
 */
$di->setShared('url', function () use($config) {
    $url = new UrlResolver();
    $url->setBaseUri($config->application->baseUri);
    return $url;
});
/**
 * Setting up the view component
 */
$di->setShared('view', function () use($config) {
    $view = new View();
開發者ID:zedmaster,項目名稱:ticobox,代碼行數:31,代碼來源:services.php

示例8: FactoryDefault

/**
 * Services are globally registered in this file
 */
use Phalcon\Mvc\Router, Phalcon\Mvc\Url as UrlResolver, Phalcon\DI\FactoryDefault, Phalcon\Session\Adapter\Files as SessionAdapter;
/**
 * The FactoryDefault Dependency Injector automatically register the right services providing a full stack framework
 */
$di = new FactoryDefault();
/**
 * Registering a router
 */
$di['router'] = function () {
    $router = new Router();
    $router->setDefaultModule("frontend");
    $router->setDefaultNamespace("Multiple\\Frontend\\Controllers");
    return $router;
};
/**
 * The URL component is used to generate all kind of urls in the application
 */
$di['url'] = function () {
    $url = new UrlResolver();
    $url->setBaseUri('/mvc/multiple-volt/');
    return $url;
};
/**
 * Start the session the first time some component request the session service
 */
$di['session'] = function () {
    $session = new SessionAdapter();
開發者ID:boiler256,項目名稱:mvc,代碼行數:30,代碼來源:services.php

示例9: Router

<?php

use Phalcon\Mvc\Router\Group;
use Phalcon\Mvc\Router;
$router = new Router();
$router->setDefaultModule('frontend');
$router->setDefaultNamespace('Myproject\\Frontend\\Controllers');
$router->add('/test-url', array('namespace' => 'Myproject\\Frontend\\Controllers', 'module' => 'frontend', 'controller' => 'index', 'action' => 'index'));
$modules = ['frontend' => ['namespace' => 'Myproject\\Frontend\\Controllers'], 'backend' => ['namespace' => 'Myproject\\Backend\\Controllers']];
foreach ($modules as $key => $module) {
    $namespace = $module["namespace"];
    $router->add('/' . $key . '/:params', array('namespace' => $namespace, 'module' => $key, 'controller' => 'index', 'action' => 'index', 'params' => 1))->setName($key);
    $router->add('/' . $key . '/:controller/:params', array('namespace' => $namespace, 'module' => $key, 'controller' => 1, 'action' => 'index', 'params' => 2));
    $router->add('/' . $key . '/:controller/:action/:params', array('namespace' => $namespace, 'module' => $key, 'controller' => 1, 'action' => 2, 'params' => 3));
}
return $router;
開發者ID:hongtien510,項目名稱:myproject,代碼行數:16,代碼來源:routes.php

示例10: Router

<?php

/**
 * 配置對應的路由模塊
 */
use Phalcon\Mvc\Router;
$router = new Router(false);
$router->removeExtraSlashes(true);
//去除多餘的"/"
///**
// * 設置路由訪問默認空間 home頁
// */
//
$router->setDefaultNamespace('myweb\\twoweb\\Controllers\\home');
////
$router->add('/', array('controller' => 'index', 'action' => 'index'));
/**
 * 設置登陸頁的路由
 */
$router->add('/:controller', array('namespace' => 'myweb\\twoweb\\Controllers\\account', 'controller' => 1, 'action' => 'index'));
$router->add('/:controller/:action', array('namespace' => 'myweb\\twoweb\\Controllers\\account', 'controller' => 1, 'action' => 2));
/**
 * 設置api接口的路由
 */
$router->add('/api/:controller', array('namespace' => 'myweb\\twoweb\\Controllers\\api', 'controller' => 1, 'action' => 'index'));
$router->add('/api/:controller/:action', array('namespace' => 'myweb\\twoweb\\Controllers\\api', 'controller' => 1, 'action' => 2));
return $router;
開發者ID:zhangchao1,項目名稱:php_design,代碼行數:27,代碼來源:router.php

示例11: Router

<?php

use Phalcon\Mvc\Router;
$router = new Router();
//Remove trailing slashes automatically
$router->removeExtraSlashes(true);
$router->setDefaultModule("backend");
$router->setDefaultNamespace("DigitalKrikits\\Backend\\Controllers");
return $router;
開發者ID:vikilaboy,項目名稱:digitalkrikits,代碼行數:9,代碼來源:routes.php

示例12: FactoryDefault

 * Services are globally registered in this file
 */
use Phalcon\Mvc\Router, Phalcon\Mvc\Url as UrlResolver, Phalcon\DI\FactoryDefault, Phalcon\Session\Adapter\Files as SessionAdapter;
/**
 * The FactoryDefault Dependency Injector automatically register the right services providing a full stack framework
 */
$di = new FactoryDefault();
/**
 * Registering a router
 */
$di['router'] = function () {
    $router = new Router();
    $router->setDefaultModule("frontend");
    $router->setUriSource(\Phalcon\Mvc\Router::URI_SOURCE_SERVER_REQUEST_URI);
    $router->removeExtraSlashes(true);
    $router->setDefaultNamespace("Bolar\\Frontend\\Controllers");
    require_once 'routes.php';
    return $router;
};
/**
 * The URL component is used to generate all kind of urls in the application
 */
$di['url'] = function () {
    $url = new UrlResolver();
    $url->setBaseUri('/mvc/multiple-volt/');
    return $url;
};
/**
 * Start the session the first time some component request the session service
 */
$di['session'] = function () {
開發者ID:karborator,項目名稱:Agency-website,代碼行數:31,代碼來源:services.php

示例13: FactoryDefault

use Phalcon\Di\FactoryDefault;
use Phalcon\Session\Adapter\Files as SessionAdapter;
use Phalcon\Mvc\Model\Metadata\Memory as MetaDataAdapter;
use Phalcon\Mvc\View;
use Phalcon\Mvc\View\Engine\Volt as VoltEngine;
/**
 * The FactoryDefault Dependency Injector automatically registers the right services to provide a full stack framework
 */
$di = new FactoryDefault();
/**
 * Registering a router
 */
$di->setShared('router', function () {
    $router = new Router();
    $router->setDefaultModule('anonymous');
    $router->setDefaultNamespace('hoctap\\Anonymous\\Controllers');
    return $router;
});
/**
 * The URL component is used to generate all kinds of URLs in the application
 */
$di->setShared('url', function () use($config) {
    $url = new UrlResolver();
    $url->setBaseUri($config->application->baseUri);
    return $url;
});
/**
 * Setting up the view component
 */
$di->setShared('view', function () use($config) {
    $view = new View();
開發者ID:nhannv56,項目名稱:hoctap,代碼行數:31,代碼來源:services.php

示例14: Router

<?php

use Phalcon\Mvc\Router;
$router = new Router();
//$router = new Router(false);
$router->removeExtraSlashes(true);
// 移除URL多餘的斜杠
//$router->setUriSource(Router::URI_SOURCE_GET_URL);
$router->setDefaultController('index');
$router->setDefaultAction('index');
$router->setDefaultModule('appApi');
$router->setDefaultNamespace('Apps\\AppApi\\Controllers');
// APP API
$router->add('/appApi', ['module' => 'appApi', 'namespace' => 'Apps\\AppApi\\Controllers\\', 'controller' => 'index', 'action' => 'index']);
$router->add('/appApi' . '/:action', ['module' => 'appApi', 'namespace' => 'Apps\\AppApi\\Controllers\\', 'controller' => 'index', 'action' => 1]);
$defaultController = 'index';
$defaultAction = 'index';
$urlBase = ['/pay' => ['module' => 'pay', 'namespace' => 'Apps\\Pay\\Controllers\\']];
foreach ($urlBase as $k => $v) {
    $module = $v['module'];
    $namespace = $v['namespace'];
    $router->add($k . '/:params', ['module' => $module, 'namespace' => $namespace, 'controller' => $defaultController, 'action' => $defaultAction, 'params' => 1]);
    $router->add($k . '/:controller/:params', ['module' => $module, 'namespace' => $namespace, 'controller' => 1, 'action' => $defaultAction, 'params' => 2]);
    $router->add($k . '/:controller/:action/:params', ['module' => $module, 'namespace' => $namespace, 'controller' => 1, 'action' => 2, 'params' => 3]);
}
return $router;
開發者ID:fu-tao,項目名稱:meelier_c,代碼行數:26,代碼來源:routers.php

示例15: Router

<?php

/**
 * User: marnixjanssen
 * Date: 6/7/15
 */
use Phalcon\Mvc\Router;
use Devnation\App\Routes\UserRoutes;
use Devnation\App\Routes\AjaxRoutes;
$router = new Router(false);
$router->setDefaultNamespace("Devnation\\App\\Controllers\\Main");
$router->add("/", ["controller" => "Index", "action" => "index"])->setName("home");
$router->add("/info/{city:[a-z\\-]+}", ["controller" => "Index", "action" => "index"]);
$router->mount(new UserRoutes());
$router->mount(new AjaxRoutes());
//$router->add("/ajax/weather/city/{city}", ["namespace" => "Devnation\\App\\Controllers\\Ajax", "controller" => "Weather", "action" => "weatherForCity"]);
//$router->add("/ajax/location/getAddress", ["namespace" => "Devnation\\App\\Controllers\\Ajax", "controller" => "Location", "action" => "getAddress"]);
//$router->add("/ajax/user/getFavorites", ["namespace" => "Devnation\\App\\Controllers\\Ajax", "controller" => "User", "action" => "getFavoriteLocations"]);
//$router->add("/ajax/user/setFavorite", ["namespace" => "Devnation\\App\\Controllers\\Ajax", "controller" => "User", "action" => "setFavoriteLocation"]);
//$router->add("/ajax/user/hasFavorite/{city}", ["namespace" => "Devnation\\App\\Controllers\\Ajax", "controller" => "User", "action" => "hasFavorite"]);
//$router->add("/ajax/user/weatherForCurrentLocation", ["namespace" => "Devnation\\App\\Controllers\\Ajax", "controller" => "User", "action" => "weatherForCurrentLocation"]);
return $router;
開發者ID:m8958,項目名稱:devnation-weather-app,代碼行數:22,代碼來源:routes.php


注:本文中的Phalcon\Mvc\Router::setDefaultNamespace方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。