php8.5
Home/ Manual/ yaf / yaf_dispatcher/ Yaf_Dispatcher::setDefaultModule

Yaf_Dispatcher::setDefaultModule

PHP function Edit on GitHub ✎

(Yaf >=1.0.0)

Change default module name

Description

Yaf_Dispatcher::setDefaultModule(string $module): Yaf_Dispatcher|null|false

Change the module name which is used when a module name can not be extracted from the request URI. The module must be a registered one, see Yaf_Application::getModules.

Parameters

module

The name of a registered module.

Return Values

Returns the Yaf_Dispatcher object itself on success, false if the given module is not registered (and a YAF_ERR_TYPE_ERROR is triggered) or if the application is not initialized, or null otherwise.

Errors/Exceptions

Triggers a YAF_ERR_TYPE_ERROR error if module is not a registered module name.

Examples

Yaf_Dispatcher::setDefaultModule example

php
<?php
$app = new Yaf_Application(dirname(__FILE__) . "/conf/application.ini");

// "Home" must be a registered module, e.g. via
// application.modules = "Index,Home,Admin" in conf/application.ini
Yaf_Dispatcher::getInstance()->setDefaultModule("Home");

$app->run();
?>

See Also

  • Yaf_Dispatcher::setDefaultController
  • Yaf_Dispatcher::setDefaultAction
  • Yaf_Dispatcher::getDefaultModule

Source: reference/yaf/yaf_dispatcher/setdefaultmodule.xml · from the official PHP manual (php/doc-en)