Although the ‘basePath’ => dirname(FILE) . DIRECTORY_SEPARATOR . ‘…’ in config file is correct, the above message indicates that the folder continues to be the “protected” folder.
either set Yii::setPathOfAlias(‘application’, dirname(FILE) . ‘../../’) or not displays the correct path, but nor works with require_once(‘myExt.php’);
Setting an alias for application manually shouldn’t be necessary. Just ensure basePath is set up correctly in your config. The application’s constructor will use this value to set up dependent aliases, which is not only the application alias. Normally, you don’t have to change anything. If I look at a default config as generated by yiic, it reads like:
// This is the main Web application configuration. Any writable
// CWebApplication properties can be configured here.
return array(
'basePath'=>dirname(__FILE__).DIRECTORY_SEPARATOR.'..',
// ...
Since the config.php is placed under protected/config, basePath is always configured correctly, even if you rename protected to something else.
Just make sure to include the correct config in your entry script. There, you can also validate configuration has been read properly:
// index.php
<?php
$yii='yii/tags/1.1.10/framework/yii.php';
require_once($yii);
// make sure to use the correct config
$config=dirname(__FILE__).'/protected/config/main.php';
$app=Yii::createWebApplication($config);
// test if configuration has been read correctly
echo Yii::getPathOfAlias('application');
die();
$app->run();
If everything is fine, let’s have a look at the extension. What makes me wonder is your require_once. This shouldn’t be needed. If it is an extension developed for yii, the autoloader should find it on its own when it is used. The following should be enough:
Yii::import('application.vendors.myvendor.*');
If you want to force inclusion of the extension at a certain point in your app, you can use: