php8.5
Home/ Manual/ yaf / yaf_loader/ Yaf_Loader::__construct

Yaf_Loader::__construct

PHP function Edit on GitHub ✎

(Yaf >=1.0.0)

The constructor is private

Description

Yaf_Loader::__construct()

Constructs a new loader. The constructor is private; Yaf_Loader is a singleton. Use Yaf_Loader::getInstance to obtain the instance.

Parameters Parameters

Return Values

No value is returned.

Examples

Obtaining the Yaf_Loader singleton

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

/* the constructor is private; use getInstance() instead */
$loader = Yaf_Loader::getInstance();
var_dump($loader instanceof Yaf_Loader);

/* instantiating directly raises an Error */
try {
    $loader = new Yaf_Loader();
} catch (Error $e) {
    echo $e->getMessage(), PHP_EOL;
}
?>

The above example will output something similar to:

output
bool(true)
Call to private Yaf_Loader::__construct() from global scope

See Also

  • Yaf_Loader::getInstance

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