本文整理汇总了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();
示例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();
示例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();
示例4: setDefaultNamespace
public function setDefaultNamespace($namespaceName)
{
return parent::setDefaultNamespace($namespaceName);
}
示例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
*/
示例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();
示例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();
示例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();
示例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;
示例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;
示例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;
示例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 () {
示例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();
示例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;
示例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;