 |
| Beginning PHP Beginning-level PHP discussions. More advanced coders should post to the Pro PHP forum. |
Welcome to the p2p.wrox.com Forums.
You are currently viewing the Beginning PHP section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
|
|
|
|

November 6th, 2003, 11:14 AM
|
|
Authorized User
|
|
Join Date: Nov 2003
Posts: 22
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
server root and php_include paths mac os x
Hi,
I'm just starting to go through PHP / MySQL website programming and it requires a few settings initialy that I'm a little unsure of due to the fact I use a mac for developement.
1. Webserver root
In the book it's /var/www/html . when I access my php_info.php file locally, there are 2 references to root, one is:
Server Root = /usr
and the other is:
DOCUMENT_ROOT = /Library/WebServer/Documents
which one should I use if I'm writing a .htaccess file with php_value include_path"etc etc" ?????
2. What's the path to php ??? The path in the book is:
/usr/lib/php/
from using the terminal I get:
/usr/local/php/lib/ or should it be /usr/local/php/ (no 'lib') ???
they also reference the 'pear' path, but that appears to be in with php here :
/usr/local/php/lib/PEAR/ on my mac, not /var/www/html/pear (a dir of the webserver)????
sorry this is a bit vague, if you need any more info just say.
thanks in advance,
Jon
|
|

November 6th, 2003, 03:16 PM
|
|
Friend of Wrox
|
|
Join Date: Jun 2003
Posts: 836
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
DOCUMENT_ROOT is the directory/folder on your filesystem which corresponds to the root path for your site's URL.
For example, if your document_root is /docroot/, and you request yoursite.com/index.html, the web server will send the file /docroot/index.html to the client.
You don't necessarily need to add an include_path to PHP's configuration unless you plan on using some external libraries/utilities (e.g. PEAR, JPGraph). PHP's include path is used when you try to include a file from your script that isn't found in the current working directory -- the system searches for it in all the directories listed in your include path before issuing a "file not found" error.
The path to PHP is wherever you installed it. Try one path. If it doesn't work, try the other.
Since you're able to view a phpinfo()-generated page, I'm willing to assume that you don't need to mess with your setup since it's already working.
Take care,
Nik
http://www.bigaction.org/
|
|

November 7th, 2003, 06:44 AM
|
|
Authorized User
|
|
Join Date: Nov 2003
Posts: 22
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
HI Nik,
OK, I think I get it now, just one more q, PEAR is installed in most versions of php by default ?? So why do I need a folder in my root driectory called pear and why do I need that path (not the path to the pear libs /usr/php/pear/ but the doc root/pear/) in the include_file ???? Thsi book is meant to be for people in a shared hosting environment, which means I don't / won't have access to the core files for php on the server.
confused,
Jon
|
|

November 7th, 2003, 06:18 PM
|
|
Friend of Wrox
|
|
Join Date: Jun 2003
Posts: 836
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Pear is *distributed* with PHP by default; that's not quite the same thing as "installed".
PEAR is a collection of utilities written IN PHP to be used by other PHP applications. The reason you need to add the pear directory to your include path is so your applications can simply include PEAR class files without having to know the absolute path to them.
In other words, when you write an application that uses a PEAR class, your script uses this line:
require_once('filename.php');
Instead of:
require_once('/path/to/pear/filename.php');
See, if you have one application, and just install the PEAR library files in the same directory you're going to develop your application in, how will your other applications include them? Do you plan to install the same files in every directory that requires them? Of course not, that would be silly. It's also silly to give other applications the ability to access directories specific to non-related applications.
You follow me?
Take care,
Nik
http://www.bigaction.org/
|
|

November 13th, 2003, 07:32 AM
|
|
Authorized User
|
|
Join Date: Nov 2003
Posts: 22
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
so, if I;ve got php 4.3 installed then I don't need to include certain files as it does in the book ??? Specifically in the class.users.php file, on page 70 of the book:
Code:
// File Location: /_lib/_classes/class.users.php
require_once("Mail.php");
require_once("DB.php");
Are these files now redundant in versions of php4.3 + ??? because I'm running this version locally and will be on the server, so can I assume that these lines can be taken out ?
It's not very clear from the book, and I'm being really hampered by this kind of stuff as I can't even get going until I know what to do.
thanks,
Jon
|
|

November 13th, 2003, 10:51 PM
|
|
Friend of Wrox
|
|
Join Date: Jun 2003
Posts: 836
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Nono -- you'll still need to include the files your application uses. Remember, I said that pear is *distributed* with PHP, not installed or built-in. All that means is that you don't have to download PEAR separately.
Take care,
Nik
http://www.bigaction.org/
|
|

November 14th, 2003, 11:15 AM
|
|
Authorized User
|
|
Join Date: Nov 2003
Posts: 22
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
HI Nik,
Still having loads of problems here, I've tried every possible path in my .htaccess file and still nothing works ! I know that the files are fine because if I use the full path (../../_lib etc) the script does'nt hang.
I've tried 3 different paths for the server root:
Library/WebServer/Documents
http://jon-bennetts-g5.local
usr
none of these have worked, but using ./firstDir/secDir/myFile.php has worked ??? I really am stumped!
Here's a little test.php code
Code:
<?php
// File Location: /test.php
// works
require_once("./_lib/_base/config.php");
// doesn't work
//require_once("config.php");
// using full path all loads of stuff outputed, without nothing
print_r(get_defined_constants());
?>
Thanks for all your help. Oh, and by the way, PEAR works fine so that include_path is ok, it';s just the paths to the classes etc that are within the site that aren't .
Jon
|
|

November 14th, 2003, 01:05 PM
|
|
Friend of Wrox
|
|
Join Date: Jun 2003
Posts: 836
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Okay, one or both of us are confused.
Quote:
quote:Originally posted by jben.net
I've tried 3 different paths for the server root:
Library/WebServer/Documents
http://jon-bennetts-g5.local
usr
none of these have worked, but using ./firstDir/secDir/myFile.php has worked ??? I really am stumped!
Here's a little test.php code
[code]<?php
// File Location: /test.php
// works
require_once("./_lib/_base/config.php");
// doesn't work
//require_once("config.php");
|
Okay, it's the include_path config setting that would affect this. If you had /path/to/_lib/_base in your include_path, then the require_once("config.php") line would work.
Quote:
quote:Originally posted by jben.net
Thanks for all your help. Oh, and by the way, PEAR works fine so that include_path is ok, it';s just the paths to the classes etc that are within the site that aren't .
|
This statement here is what confuses me; I don't quite follow what you mean. If PEAR works, then the paths to the classes must also work, since they're part of the PEAR library.
Perhaps I'm overworked. Can you do me a huge favor: start over and give me the details of what works and what doesn't? When you mention your config settings, tell me where the settings are defined (e.g. php.ini, httpd.conf, .htaccess) and give me the EXACT line from that file that sets the option.
Tell me what you expect that option to do, and why you think that option does or does not work.
Reason I'm asking is that ServerRoot is (iirc) an APACHE setting, not a PHP one, so it shouldn't have any effect on whether you should be able to include files from within PHP...
Take care,
Nik
http://www.bigaction.org/
|
|

November 14th, 2006, 07:08 AM
|
|
Registered User
|
|
Join Date: Nov 2006
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Could you show exactly what you have to put in the .htaccess file.
Also when unzipping the PEAR extensions where abouts do you place them in relation to the PEAR base class and should we change the root directory name of the extension e.g. "Mail 1.2.1" so change it to "Mail"
|
|
 |