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

Yaf_Dispatcher::__construct

PHP function Edit on GitHub ✎

(Yaf >=1.0.0)

Yaf_Dispatcher constructor

Description

Yaf_Dispatcher::__construct()

Yaf_Dispatcher implements the singleton pattern, so the constructor is private. Use Yaf_Dispatcher::getInstance to retrieve the dispatcher instance, which is created by Yaf_Application.

Parameters Parameters

Return Values

Void

Examples

Yaf_Dispatcher is a singleton

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

// Yaf_Dispatcher implements the singleton pattern, so its constructor is
// private. Retrieve the instance with Yaf_Dispatcher::getInstance()
// instead of calling `new`.
$dispatcher = Yaf_Dispatcher::getInstance();

var_dump($dispatcher instanceof Yaf_Dispatcher);
?>

The above example will output something similar to:

output
bool(true)

See Also

  • Yaf_Dispatcher::getInstance
  • Yaf_Application::getDispatcher

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