Including External Files

How can i include and use another PHP files on Yii.

For example, i’ll use Facebook PHP SDK .

Normally, we can use it like this


/* Facebook class is declared on facebook.php file */

$facebook = new Facebook(array(

  'appId'  => 'YOUR_APP_ID',

  'secret' => 'YOUR_APP_SECRET',


// Get User ID

$user = $facebook->getUser();

Now how can i integrate it to Yii framework ?

Please explain step by step :)


There is only one step:




That assumes that it’s placed in app/protected/vendors.

Thank you. What is the difference of vendors and components ?

Vendors = 3rd party code, like extensions, but extensions are Yii-oriented. And components dir is for your own classes used in the current application (widgets, menus, etc.).