12, October 2008

$DOCUMENT_ROOT change - webmaster forum

 
Webdigity webmaster forums
This forum shares its ad revenue with its members!
[ Home | Help | Search | Forum's Shop | Archive | Login | Register | Webmaster Directory ]
Webdigity Webmaster Forums  >  Web Development  >  PhP  >  PHP classes @finalwebsites.com  >  Access_user Class (Moderator: Olaf)
Topic: $DOCUMENT_ROOT change
« previous next »
Pages: [1] Print

Author Topic: $DOCUMENT_ROOT change  (Read 840 times)
Chicken-run Manager
*
Gender: Male
Posts: 9
62 credits
Members referred : 0



« on: Aug 18, 2006, 04:32:47 AM »

Hello everone !
Thought to mention the fact that I had to adjust the latest access_user class code to a few minor server related issues that might be of interest to you all (or not). And correct me if I am wrong (and I might very well be..) The $DOCUMENT_ROOT variable that is a server defined value (might even be a php.ini def..) becomes a little bit of a problem if you are running multiple web sites on the same server, each one being a "virtual" host (I am on Apache by the way) In other words the $DOCUMENT_ROOT needs to point in a few locations in the file directory.
Well, first I thought..hmm...lot of work going in and hard code these values, not a good idea in any case, so for now I added the following line to resolve the include and for a bit more portabilty

$DOCUMENT_ROOT = "/home/meuser/www/websitename";
include($DOCUMENT_ROOT."/classes/access_user/access_user_class.php");
instead of :
include($_SERVER['DOCUMENT_ROOT']."/classes/access_user/access_user_class.php");

now this works out ok, for now, and it might perhaps be a little dirty, maybe there is a better solution, but for now it will suffice !
Plus I do like the idea , like you I suppose, of keeping my php classes separate and not mingled in with the rest of the html and graphics content pertaining to the web site. php the oo way, like  Wink

Again thanks for excellent work !

Ha'de
Anders
Moderator
Community Supporter ?
Jedai Sword Master
*****
Gender: Male
Posts: 6349
38918 credits
Members referred : 374


It's time to use PHP5!


« Reply #1 on: Aug 18, 2006, 09:35:59 AM »

hello Anders,

I use apache at my localhost too and have arround 20 virt. hostings on my laptop, each of them has it's own document_root. Remember that kind of configuartion is similar to the most shared web hosting  accounts.

but of course you can change the pathes to whatever you want, I created two variable just as an example to make it easier inside the different files.

I think its also hard stuff for beginning php developers to learn and understand the include command...


Last blog : Upload images for usage in TinyMCE
Chicken-run Manager
*
Gender: Male
Posts: 9
62 credits
Members referred : 0



« Reply #2 on: Aug 19, 2006, 10:39:21 AM »

Absolutely correct Olaf, when it comes to your php class with document root variable used the way it is used. I have a number of virtual hosts defined as well. There is also a document root defined in the httpd.conf file, not to be consfused with the document root that you are using. I believe $DDOCUMENT_ROOT is defined in the php.ini file ? Correct me if I am wrong...however, to quickly resolve a few issues I did the mentioned change, but I will extend your class to cover all my web site requirements, and special needs. In this case, extending your class further I will be using document root in the way you have suggested, and point the root in one and the same place. Bare with me, I really think this class shows an excellent way of thoughtful and reusable sw design, and I was not expecting that kind of quality from a "mere" scripting language...shame on me old bad C geek !! You certainly showed me some good php grips ! I will follow suit Smiley
Moderator
Community Supporter ?
Jedai Sword Master
*****
Gender: Male
Posts: 6349
38918 credits
Members referred : 374


It's time to use PHP5!


« Reply #3 on: Aug 19, 2006, 11:04:27 AM »

Don't wanna teach you Cheesy
If you configure the document root inside Apache then it's possible to leave this value in PHP empty:

check this install tutorial: http://www.apptools.com/phptools/virtualhost.php Visit through proxy


Last blog : Upload images for usage in TinyMCE
Moderator
Community Supporter ?
Jedai Sword Master
*****
Gender: Male
Posts: 6349
38918 credits
Members referred : 374


It's time to use PHP5!


« Reply #4 on: Aug 19, 2006, 11:07:08 AM »

...something else, this way Anders described is absolutly OK, but be sure that your configuration has this php setting: "register_gloabals = off"


Last blog : Upload images for usage in TinyMCE
Trackback URI for this entry : http://www.webdigity.com/trackback.php?topic=3728
Tags : html apache graphics php.ini httpd.conf Bookmark this thread : Digg Del.icio.us Dzone more....

Topic sponsors:
Get a permanent link here for $1.99!


Pages: [1] Print 
Webdigity Webmaster Forums  >  Web Development  >  PhP  >  PHP classes @finalwebsites.com  >  Access_user Class (Moderator: Olaf)
Topic: $DOCUMENT_ROOT change
« previous next »
Jump to:
User Area
Welcome, Guest. Please login or register.
Did you miss your activation email?
Oct 12, 2008, 05:02:52 AM





Login with username, password and session length

Donate to our community, and get a permanent link back to your site!

Donate to our community, and get a permanent link back to your site!


Forum Statistics
Total Posts: 36.906
Total Topics: 7.558
Total Members: 4.150
Tutorials : 56
Resources : 143
Designs : 220
Latest Member: neli67

15 Guests, 4 Users online :

13 users online today:



Readers

Web Design Gallery · Whois Lookup · Pagerank · Tag Browsing · Lo-fi version · Syndication · Webmaster forum history · Advertise
Developed by HumanWorks © 2005 - 2008 Webdigity webmaster community · sublime directory
Webdigity Webmaster Forums | Powered by SMF 1.0.12. © 2001-2005, Lewis Media. All Rights Reserved.