0

I copy some Zend libraries and paste them into libraries folder in CodeIgniter. I try to use this code, it's ok:

$this->zend->load('zend/json');

$data = array(
    'name' => 'Killer Whale',
    'email' => 'namnguyen2091@gmail.com',
    'website' => 'baogiadientu.com'
);

// load and encode data
$json = new Zend_Json();
$encode = $json->encode($data);
echo $encode;

//decode with static function
echo '<pre>';
print_r(Zend_Json::decode($encode));
echo '</pre>';

But when I code like below, it doesn't work and I get an error: Fatal error: Class 'Zend_Config_Writer_Xml' not found in D:\Programs\xampp\htdocs\baogiadientu\application\controllers\product.php on line 83

$this->zend->load('zend/config');

// create the config object
$config = new Zend_Config(array(), true);
$config->production = array();

$config->production->webhost = 'baogiadientu.com';
$config->production->database = array();
$config->production->database->params = array();
$config->production->database->params->host = 'localhost';
$config->production->database->params->username = 'root';
$config->production->database->params->password = '123456';
$config->production->database->params->dbname = 'baogiadientu';

$writer = new Zend_Config_Writer_Xml(); // **here**
echo $writer->toString($config);

I follow this article http://framework.zend.com/manual/2.0/en/modules/zend.config.writer.html. Please help me!

Killer Whale
  • 55
  • 1
  • 8

2 Answers2

1

You are trying to do two things there (1) load and instantiate a Zend Config object and (2) do the same with Zend_Config_Writer_Xml - all without including the required files.

You may just need to require("Zend/Config.php") and require("Zend/Config/Writer/Xml.php") after ensuring they are inside your include_path

kguest
  • 3,804
  • 3
  • 29
  • 31
  • But I loaded by this code $this->zend->load('zend/config'); $config = new Zend_Config(array(), true); ? – Killer Whale Dec 16 '13 at 09:19
  • It seems then that the Zend code isn't inside your include path, looking at http://stackoverflow.com/questions/12255888/how-to-combine-zend-framework-and-codeigniter?rq=1 as a reference you should be able to get things working. – kguest Dec 16 '13 at 09:33
1

You are using a ZF1 library with the ZF2 documentation

Please check the correct documentation at their website:

http://framework.zend.com/manual/1.12/en/zend.config.writer.introduction.html

Dirkos
  • 488
  • 1
  • 10
  • 33