PHP 8.5.10 Released!

Yaf_Registry::set

(Yaf >=1.0.0)

Yaf_Registry::setAdd an item into registry

Description

public static function Yaf_Registry::set(string $name, mixed $value): bool

Stores a value in the registry. Setting an already existing name overwrites its previous value.

Parameters

name

The name of the registry entry.

value

The value to store; it may be of any type, including objects.

Return Values

Returns true on success, or false on failure.

Examples

Example #1 Yaf_Registry::set() example

<?php
class Bootstrap extends Yaf_Bootstrap_Abstract
{
    public function _initRedis(Yaf_Dispatcher $dispatcher)
    {
        $config = Yaf_Application::app()->getConfig()->redis;

        $redis = new Redis();
        $redis->connect($config->host, $config->port);

        /* the connection is now available to the whole application */
        Yaf_Registry::set("redis", $redis);
    }
}
?>

See Also

add a note

User Contributed Notes

There are no user contributed notes for this page.
To Top