URL's from a path or a "path alias"?

Hi guys,

I’m having a mess trying to figure out how to get URL’s from a certain public path (not in protected dir) or from a path alias…

Using Yii::getPathOfAlias I can get the physical path and I see UrlManager is more focuse on Controllers and Actions, etc, so …

someone can give me an idea?



I would just use your path directly from from the base url.




Or what "exactly" do you want to do?

Is this of any use?

get current webpage in yii? how?

thx guys… in the code of my ImageApi extension I’d like to offer for the generated images 2 methods:

  • createPath: path to the dynamically generated file

  • createUrl: url just to plug in the src of an img tag

finally I’m using what horizons said removing the “webroot path” from the generated path and appending the “baseUrl” from Yii:

      $targetPath = Yii::getPathOfAlias($preset['cacheIn']); 

      $generatedPath = $this->createPath($presetName, $file);


      $webrootPath = Yii::getPathOfAlias('webroot');

      if(strpos($generatedPath, $webrootPath) !== FALSE) {

        $generatedPath = substr($generatedPath, strlen($webrootPath));


      $generatedUrl = str_replace('\\', '/', Yii::app()->urlManager->getBaseUrl().$generatedPath);

Thanks to both, guys!