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

Yaf_Dispatcher::setDefaultController

PHP function Edit on GitHub ✎

(Yaf >=1.0.0)

Change default controller name

Description

Yaf_Dispatcher::setDefaultController(string $controller): Yaf_Dispatcher|null|false

Change the controller name which is used when a controller name can not be extracted from the request URI. The name is normalized to capitalize the first letter.

Parameters

controller

The name of the controller.

Return Values

Returns the Yaf_Dispatcher object itself on success, or false if the application is not initialized.

Examples

Yaf_Dispatcher::setDefaultController example

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

// Requests without a controller part now go to HomeController, the name
// is normalized to capitalize the first letter
Yaf_Dispatcher::getInstance()->setDefaultController("home");

$app->run();
?>

See Also

  • Yaf_Dispatcher::setDefaultModule
  • Yaf_Dispatcher::setDefaultAction
  • Yaf_Dispatcher::getDefaultController

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