Hello I need to use evalmath.class.php within a Yii application. How can I include it from my controller?
Something like this:
public function actionFormulas() {
include('models/evalmath.class.php');
$m = new EvalMath;
...
}
But the above code does not work. How can I include an external class within a controller?
In your example, to use include/require you probably need to add some path info with
dirname(__FILE__).'/../models/...'or similar, but to do it within the Yii framework, you would first create an alias (usually in your main config file) with setPathOfAlias :Then you can use Yii::import like so:
and proceed as you were: