read feeds using Zend Feed + EHttpClient

Hi

I’m here to share a way to use Zend_Feed_Reader with the EHttpClient extension

Why use EHttpClient and not to use Zend_Autoloader?

To use less Zend dependencies, speeding it up

How to use:

download EHttpClient extension and extract it in your extensions folder

Also, extract the content of the attached file to application.vendors folder and apply this code anywhere you want to use Zend_Feed




    	//add zend folder to the include path and save the old one

    	$oldPath=set_include_path(($path=Yii::import('application.vendors.*')).PATH_SEPARATOR.get_include_path());

    	//include zend_loader

    	require_once $path.DIRECTORY_SEPARATOR.'Zend'.DIRECTORY_SEPARATOR.'Loader.php';

    	//load zend_feed class

    	Zend_Loader::loadClass('Zend_Feed');

    	//read the feed, try/catch will prevent it from throw an exception

    	try{ 

        	$dataProvider=Zend_Feed::import('http://www.yiiframework.com/rss.xml/');

    	}catch(CException $e){ 

        	Yii::log($e->getMessage(),CLogger::LEVEL_WARNING);

        	$dataProvider=array(); 

    	}

    	//after you use zend classes, remove zend from included paths to increase perfomance

    	set_include_path($oldPath);



The modified Zend_Feed is attached

Hope it helps

Gustavo

Very cool Gustavo…

This is an excellent solution.

Thank you!

Excelent! - this only one extension which working for me.