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

Yaf_Dispatcher::setDefaultAction

PHP function Edit on GitHub ✎

(Yaf >=1.0.0)

Change default action name

Description

Yaf_Dispatcher::setDefaultAction(string $action): Yaf_Dispatcher|null|false

Change the action name which is used when an action name can not be extracted from the request URI. The name is normalized to lowercase.

Parameters

action

The name of the action.

Return Values

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

Examples

Yaf_Dispatcher::setDefaultAction example

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

// Requests without an action part are now routed to "main" instead of
// "index", e.g. /user maps to UserController::mainAction
Yaf_Dispatcher::getInstance()->setDefaultAction("main");

$app->run();
?>

See Also

  • Yaf_Dispatcher::setDefaultModule
  • Yaf_Dispatcher::setDefaultController
  • Yaf_Dispatcher::getDefaultAction

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