[Solved]Assetmanager help is required

Hi all,

I want to publish images of my extension but I am unable to do that.

I have set

        $dir = dirname(__FILE__) . DIRECTORY_SEPARATOR;

        $baseUrl = Yii::app()->getAssetManager()->publish($dir . 'assets',true);

but it does not work.

Please help me in this regard.


Maybe it’s obvious… .but have you checked that the value of $dir corresponds to the actual folder where you have those images

Try this this works for me


$dir = dirname(__FILE__).'/assets';

$this->baseUrl = Yii::app()->getAssetManager()->publish($dir);

Well, I’m using something like this:

$dir = dirname(__FILE__) . DIRECTORY_SEPARATOR . 'source';

$this->baseUrl = Yii::app()->getAssetManager()->publish($dir);

And this surely works! It is not specially different than your code. Therefore, as mdoba advised you, I would check, if you have any files in your source dir or if it really exists, as it seems problem lies here.

Just keep in mind that this requires that the directory in question is in the same directory as that FILE.

Not one up or one down.

Within the directory of FILE.

thanks you all.


would be nice if you can write what was the problem and what have you changed for making it work… so that in the future users with similar problem can read your solution…


Unable to publish the assets of the extension i.e. images.


The solution was posted by the Trejder. I just modified it a bit to make it working properly for my extension.

$dir = dirname(__FILE__).'/assets';

$this->baseUrl = Yii::app()->getAssetManager()->publish($dir);