Loading an existing PHP file of functions

I have an existing PHP web application that includes a file of functions (not a class, just functions).

Is there a good way to include that file in my yii application, while keeping it in it’s current directory location (i.e. not moved to a yii protected sub-directory)? It won’t be feasible to simply wrap the file in a class, since the functions in that file are used extensively in the existing web application.

FWIW - my goal is to retain the existing web application while moving functionality to the yii version. It will be necessary to maintain both for a period of time.

Why can’t you just do a include/require?

I prefer to do it directly in index.php.

Here’s how it looks:




// change the following paths if necessary

$yii = dirname(__FILE__).'/../framework/yii.php';

$config = dirname(__FILE__).'/protected/config/main.php';


// my convenient functions

$utils = dirname(__FILE__).'/protected/utils.php';


require_once($utils);

require_once($yii);



I’d rather use




Yii::import(<path_alias>);



http://www.yiiframework.com/doc/api/1.1/YiiBase#import-detail

Hope it helps

You can also convert your functions into static methods in a helper class.