I sometimes find myself offline and needing to do web development. As I work mostly with php getting access to the PHP manual can be critical. Without being online the only way to do this is to store a local copy.
Now, I had a few problems getting this to work. Little documentation and a fuzzy head were the main causes. Anyway, I got there in the end so here’s what I did. Pre-requisites are that you have a copy of MAMP (non-pro version) installed and have downloaded and unzipped the manual file.
Copy the manual file somewhere sensible in your localhost root folder. I put mine into /Sites/root/phpmanual/ giving the localhost url of http://localhost/root/phpmanual/php-chunked-xhtml/.
Next, work out which php.ini file you’re using. To do this create and open a phpinfo.php file. A phpinfo.php file just needs the following:
<?php phpinfo(); ?>
Search for php.ini and you’ll see a line in the row with a heading of Loaded Configuration File. You’ll have a url of something like: /Applications/MAMP/conf/php5.3/php.ini. Open this file in TextWrangler and make the edits below. Make sure you make a copy of the php.ini file before doing this or have some way to restore the original version.
- Change display_errors to On.
- Change html_errors to On.
- Add base url to docref_root and uncomment (delete the semi-colon). In my case the base url is /root/phpmanual/php-chunked-xhtml/.
- Uncomment error_prepend_string.
- Uncomment error_append_string.
277 display_errors = On 311 html_errors = On 319 docref_root = "/ROOT/phpmanual/php-chunked-xhtml/" 320 docref_ext = .html 323 error_prepend_string = "<font color=ff0000>" 326 error_append_string = "</font>"
The final thing to do is save the file and then restart your servers. To test it create a basic php file like the one below.
<?php include ('file.php'); ?>
Launch it and you should see this
Warning: include(file.php) [function.include.html]: failed to open stream: No such file or directory in /Users/zoooj/Sites/root/mailout.php on line 2 Warning: include() [function.include.html]: Failed opening 'file.php' for inclusion (include_path='.:/Applications/MAMP/bin/php5.3/lib/php') in /Users/zoooj/Sites/root/mailout.php on line 2
Click on the links (in blue) and you’ll be taken to your local copy of the PHP Manual. These links point to my local copy so probably won’t work for you, unless you’ve set it up and used the same location as I have. Simply by regularly updating the manual you can now work offline whenever you want on your php development.