Yii Framework Forum: basePath - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • This topic is locked

basePath really? Rate Topic: ***** 1 Votes

#1 User is offline   Backslider 

  • Advanced Member
  • PipPipPip
  • Yii
  • Group: Members
  • Posts: 358
  • Joined: 23-July 09

Posted 12 October 2009 - 05:30 PM

The docs define basePath as: "the root directory of the application."

So, why does echo Yii::app()->basePath; always return /mypath/protected/ ?

It would be far more useful if it returned the expected /mypath/

It seems we have nice easy properties for all the expected directories: modulePath, extensionPath,runtimePath,basePath(/protected/) except the actual root.

How about adding one?
We were all once expert at....... nothing.

yii-language-behavior

My Blog
0

#2 User is offline   mbi 

  • Master Member
  • PipPipPipPip
  • Yii
  • Group: Members
  • Posts: 604
  • Joined: 08-May 09

Posted 13 October 2009 - 01:40 AM

maybe this is an option?

http://www.yiiframew...riptFile-detail
0

#3 User is offline   maxxdev 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 12
  • Joined: 02-October 09

Posted 13 October 2009 - 10:55 AM

dirname(Yii::app()->request->scriptFile)
take a look here
0

#4 User is offline   Backslider 

  • Advanced Member
  • PipPipPip
  • Yii
  • Group: Members
  • Posts: 358
  • Joined: 23-July 09

Posted 13 October 2009 - 08:24 PM

Thanks, I knew there was a way, but still think it should be a property like the others :)
We were all once expert at....... nothing.

yii-language-behavior

My Blog
0

#5 User is offline   pangjanne 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 118
  • Joined: 01-July 09

Posted 13 October 2009 - 08:43 PM

basePath point to '/protected' may be convention.
you can get the "/yourWeb" relative URL by baseUrl property;
0

#6 User is offline   Backslider 

  • Advanced Member
  • PipPipPip
  • Yii
  • Group: Members
  • Posts: 358
  • Joined: 23-July 09

Posted 13 October 2009 - 09:00 PM

I am after the full file system path. This is for simple procedures such as a user uploading images. As such, it should be available as a standard property.

dirname(Yii::app()->request->scriptFile) works, so that is what I will use.
We were all once expert at....... nothing.

yii-language-behavior

My Blog
1

#7 User is offline   pangjanne 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 118
  • Joined: 01-July 09

Posted 13 October 2009 - 11:17 PM

you can config you main.php,
params = array(
...
'webRoot' => dir(dirname(__FILE__).DIRECTORY_SEPARATOR.'..')
)

call Yii::app()->params['webRoot'], :rolleyes:
0

#8 User is offline   Backslider 

  • Advanced Member
  • PipPipPip
  • Yii
  • Group: Members
  • Posts: 358
  • Joined: 23-July 09

Posted 14 October 2009 - 01:39 AM

That just throws an error:

Object of class Directory could not be converted to string

We were all once expert at....... nothing.

yii-language-behavior

My Blog
0

#9 User is offline   Dave 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 187
  • Joined: 09-October 08

Posted 14 October 2009 - 04:21 AM

leave out the dir()
0

#10 User is offline   Backslider 

  • Advanced Member
  • PipPipPip
  • Yii
  • Group: Members
  • Posts: 358
  • Joined: 23-July 09

Posted 14 October 2009 - 01:31 PM

View PostBackslider, on 13 October 2009 - 09:00 PM, said:

I am after the full file system path. This is for simple procedures such as a user uploading images. As such, it should be available as a standard property.

dirname(Yii::app()->request->scriptFile) works, so that is what I will use.


I think we have lost the point of my first post and now are looking at everything that does NOT work.

My original point was that a property that points to the root directory of the application should be available, just as it is for other directories such as modulePath, extensionPath, runtimePath etc.
We were all once expert at....... nothing.

yii-language-behavior

My Blog
0

#11 User is offline   mbi 

  • Master Member
  • PipPipPipPip
  • Yii
  • Group: Members
  • Posts: 604
  • Joined: 08-May 09

Posted 14 October 2009 - 03:54 PM

View PostBackslider, on 14 October 2009 - 01:31 PM, said:

I think we have lost the point of my first post and now are looking at everything that does NOT work.

My original point was that a property that points to the root directory of the application should be available, just as it is for other directories such as modulePath, extensionPath, runtimePath etc.


you can request this feature here
http://www.yiiframew...ature-requests/

the dev team will decide B)
0

#12 User is offline   Backslider 

  • Advanced Member
  • PipPipPip
  • Yii
  • Group: Members
  • Posts: 358
  • Joined: 23-July 09

Posted 14 October 2009 - 04:06 PM

View Postmbi, on 14 October 2009 - 03:54 PM, said:

you can request this feature here
http://www.yiiframew...ature-requests/

the dev team will decide B)



Doh! Thanks! :P
We were all once expert at....... nothing.

yii-language-behavior

My Blog
0

#13 User is offline   pangjanne 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 118
  • Joined: 01-July 09

Posted 15 October 2009 - 04:00 AM

modify
'webRoot' => dir(dirname(__FILE__).DIRECTORY_SEPARATOR.'..')

to
'webRoot' => dirname(dirname(__FILE__).DIRECTORY_SEPARATOR.'..')

0

#14 User is offline   mbi 

  • Master Member
  • PipPipPipPip
  • Yii
  • Group: Members
  • Posts: 604
  • Joined: 08-May 09

Posted 20 October 2009 - 11:02 AM

Yii::getPathOfAlias('webroot')

0

#15 User is offline   ricardograna 

  • Advanced Member
  • PipPipPip
  • Yii
  • Group: Members
  • Posts: 376
  • Joined: 31-March 09
  • Location:Manaus/AM - Brazil

Posted 20 October 2009 - 03:53 PM

CORRECTION:
YiiBase::getPathOfAlias('webroot')

Yes, It Is!
0

#16 User is offline   Mike 

  • Elite Member
  • PipPipPipPipPip
  • Yii
  • Group: Members
  • Posts: 3,013
  • Joined: 06-October 08
  • Location:Upper Palatinate

Posted 21 October 2009 - 02:36 AM

CORRECTION OF CORRECTION: ;)

Yii extends YiiBase so Yii::getPathOfAlias() is valid.
0

#17 User is offline   ricardograna 

  • Advanced Member
  • PipPipPip
  • Yii
  • Group: Members
  • Posts: 376
  • Joined: 31-March 09
  • Location:Manaus/AM - Brazil

Posted 21 October 2009 - 08:48 AM

Sure? That's strange, didn't worked for me when tried it.
Yes, It Is!
0

#18 User is offline   Mike 

  • Elite Member
  • PipPipPipPipPip
  • Yii
  • Group: Members
  • Posts: 3,013
  • Joined: 06-October 08
  • Location:Upper Palatinate

Posted 21 October 2009 - 08:51 AM

Yes, just verified that it really works. What error do you get?
0

#19 User is offline   bks07 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 4
  • Joined: 31-October 11

Posted 22 November 2011 - 06:52 AM

What about...

Yii::app()->basePath . '../';


:)

View PostBackslider, on 12 October 2009 - 05:30 PM, said:

The docs define basePath as: "the root directory of the application."

So, why does echo Yii::app()->basePath; always return /mypath/protected/ ?

It would be far more useful if it returned the expected /mypath/

It seems we have nice easy properties for all the expected directories: modulePath, extensionPath,runtimePath,basePath(/protected/) except the actual root.

How about adding one?

1

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • This topic is locked

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users