Chicken-run Manager
Gender:
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
Again thanks for excellent work !
Ha'de Anders
Moderator Community Supporter?
Jedai Sword Master
Gender:
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...
Chicken-run Manager
Gender:
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
Moderator Community Supporter?
Jedai Sword Master
Gender:
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 If you configure the document root inside Apache then it's possible to leave this value in PHP empty: