Using Third Party Library With Namespace

I am trying to use http://openweathermap.org/api which can be downloaded from https://github.com/c...therMap-PHP-Api in my yii application

I have extracted the Cmfcmf folder under vendors folder in my application as you can see the folder content

protected/vendor/

└── Cmfcmf

├── OpenWeatherMap


│   ├── AbstractCache.php


│   ├── CurrentWeather.php


│   ├── Exception.php


│   ├── Fetcher


│   │   ├── CurlFetcher.php


│   │   ├── CurlFetcherTest.php


│   │   ├── FetcherInterface.php


│   │   ├── FileGetContentsFetcher.php


│   │   └── FileGetContentsFetcherTest.php


│   ├── Forecast.php


│   ├── History.php


│   ├── Util


│   │   ├── City.php


│   │   ├── Sun.php


│   │   ├── SunTest.php


│   │   ├── Temperature.php


│   │   ├── Time.php


│   │   ├── Unit.php


│   │   ├── UnitTest.php


│   │   ├── Weather.php


│   │   └── Wind.php


│   ├── WeatherForecast.php


│   └── WeatherHistory.php


└── OpenWeatherMap.php

then [size="2"]added the following lines of code to my main.php in config folder to set the alias of the namespace Cmfcmf :[/size]


Yii::setPathOfAlias('Cmfcmf',Yii::getPathOfAlias('application.vendors.Cmfcmf'));



then auto import the vendor as below




  'import' => array(

	.....

	......

        'application.vendors.*',

        ...

    ),

but the problem is whenever I try to use it as below


$wd=new Cmfcmf\OpenWeatherMap();

I got 500 internal server error as below

[color="#FCE94F"]size=“2”[/size][/color] Fatal error: Class ‘Cmfcmf\OpenWeatherMap’ not found in /var/www/html/his_tb/protected/views/page/charter-quotes.php on line 28

[i]

[/i]

anyone can help?!

thanks in advanced.

[i]

[/i]

Have you followed the instructions given here? http://www.yiiframework.com/doc/guide/1.1/en/basics.namespace#namespaced-classes

Thank you Bizley

I have replaced


Yii::setPathOfAlias('Cmfcmf',Yii::getPathOfAlias('application.vendors.Cmfcmf'));

with


Yii::setPathOfAlias('Cmfcmf',dirname(__FILE__) . '/../vendors/Cmfcmf');

and that solved the problem.

Glad I could help :)