Showing posts with label yii url. Show all posts
Showing posts with label yii url. Show all posts

Thursday, April 5, 2012

URL in yii Framework

Maybe sometime you are confuse about the standard getting url in Yii Framework. You can use some of the pattern below of the url in yii framework

FULL URL ==> http://www.example.com:8080/project/index.php?r=post/view&id=123

PROPERTY
hostInfo     http://www.example.com:8080
port                                8080
baseUrl                                 /project
url                                     /project/index.php?r=post/view&id=123
requestUri                              /project/index.php?r=post/view&id=123
scriptUrl                               /project/index.php
queryString                                                r=post/view&id=123
scriptFile                 /var/www/html/project/index.php

You can access this url with the code of url :


Yii::app()->request->hostInfo;
Yii::app()->request->port; 
Yii::app()->request->baseUrl;
Yii::app()->request->url; //and the other property

Now You can choose your property you need