Renaming The Protected Folder

Hi Everyone

I want to rename the protected folder, so

I set the $config in index.php to

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

Everything works ok except an issue

Trying to include a file like this



An error occurs


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.

what I missed ?


Try setting an alias in your config/main.php At the very top:

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

Or something like that. Just see how many levels up is your newly named category.

Hope this helps

Thanks for your response Bettor

But the problem remains, I thing all referenced alias on protected folder inherit the basePath setting

so, I was respect to work without any other changing

Also I check the path of alias by

echo Yii::getPathOfAlias('application.vendors.smarty.*'); die();

either set Yii::setPathOfAlias(‘application’, dirname(FILE) . ‘../../’) or not displays the correct path, but nor works with require_once(‘myExt.php’);

Any suggestion?


did you check the extension code? meybe there is hardcoded path ‘protected’ somwhere there?

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(


// ...

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




// make sure to use the correct config



// test if configuration has been read correctly

echo Yii::getPathOfAlias('application');



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:


If you want to force inclusion of the extension at a certain point in your app, you can use:


Hi redguy

I always avoid to use hardcode, especially for path and urls :)

I check that yesterday

echo Yii::getPathOfAlias('application.vendors.smarty.*'); die(); //show the corrected path


require_once('myExt.php'); //the error occurs 

Hi Ben, I agree with you,

The extension is not writing for yii, so I thing the require_once is necessary

Something strange happens in my issue

I post back when I have more information

Ok the problem solved!

I have set APC cache on Controller!

There was a reason not full undestanding by me, that a partly of code run correctly and another one did not.

If anyone has similar issue please share it.

Thanks Redguy and Ben for repsonse :)

weird… but happily you solved this :)