Note that there are some explanatory texts on larger screens.

plurals
  1. POWhat is the right path for PHP includes on a Mac?
    text
    copied!<p>Running Mac OS X 10.5.8, with PHP 5.2.11 Pre-installed. Using Coda 1.6.10.</p> <p>I'm writing PHP files, and then preview them running from file, not server. This was working fine till I tried PHP includes. These don't work as a relative path, only as an absolute from the root of the drive.</p> <p>Is there any way I can use statements like </p> <blockquote> <p>include_once "common/header.php"; </p> </blockquote> <p>without specifying my entire file path like so : </p> <blockquote> <p>include_once "/Volumes/Macintosh HD/Users/neil/Desktop/Website/ColoredLists_v1.0/common/base.php";</p> </blockquote> <p>,where ColoredLists_v1.0 is the directory with all the website files in it. I tried solutions like prepending _SERVER[DOCUMENT_ROOT] or dirname(<strong>File</strong>) to the file paths, but that didn't work as the variables were not set. Is there any easy way to do this, or a configuration I can change so that it looks in a specific directory by default instead of looking at the drive root? Currently, echo_include_path shows .:</p> <p>When I include this line at the start of the script, it works:</p> <blockquote> <p>set_include_path('/Volumes/Macintosh HD/Users/neil/Desktop/Website/ColoredLists_v1.0');</p> </blockquote> <p>However, if I want to do this for all my scripts, I can't seem to make the change permanent. Even after I edited the Unix include_path in my php.ini, it doesn't seem to work.</p> <p>UPDATE: I finally decided that the easiest sureshot way was to run the Apache server locally. It comes preinstalled with Mac, so didnt face much trouble there. I modified the httpd.conf to only allow connections from localhost, thus alleviating my security fears. Ofcourse, this still opens up port 80, but I'm behind a router, so I'm gonna hope I'm not very exposed. And Coda includes a great features in 'Sites', where I can set the local url, so it works brilliantly now. Only downside is, now, after code edits, I need to manually refresh the preview.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload