if (Zend_Registry::isRegistered('dbAdapter')) { $dbAdapter = Zend_Registry::get('dbAdapter'); } else { $dbAdapter = new Zend_Db_Adapter_Mysql(array( 'host' => 'localhost', 'username' => 'username', 'password' => 'password', 'dbname' => 'database' )); Zend_Registry::set('dbAdapter', $dbAdapter); }
if (!Zend_Registry::isRegistered('config')) { $configFile = APPLICATION_PATH . '/configs/application.ini'; $config = new Zend_Config_Ini($configFile, APPLICATION_ENV); Zend_Registry::set('config', $config); }In this example, the isRegistered method is used to check if the 'config' object has not been registered in the registry. If it hasn't been registered, a new instance of the Zend_Config_Ini class is created from an INI file and registered using the set method. In conclusion, Zend_Registry is part of the Zend Framework package library and is used for creating a centralized registry for sharing objects across a PHP application. The isRegistered method is used to check if an object has already been registered in the registry.