Setting up local copy of PHP manual – with smart lookups
If you are a PHP developer, you probably know that you can type “php.net/substr” to look at documentation for the substr() function. This works for many other keywords as well and is a superb feature. It’s just so convenient, I stopped using my local copy of PHP manual.
But yesterday, I wanted it offline. I downloaded the “many HTML files” version of the documentation, extracted it and set it up on my local Apache. I can now open up http://localhost/phpman/ to read the documentation. (this is how I actually learned PHP 11 years ago!!)
And I wanted the smart lookups – auto complete! I searched around to find if there was a ready .htaccess file that I could use. Or if someone had made something similar already. I did not really find anything solid. Suddenly I realized I can just look up the PHP.net site source code and figure out what they are doing, and replicate it on my local setup. (Yes, PHP.net’s source code is open too!)
Eureka!
So after a few minutes of hacking around, I have my nice little setup that mimics PHP.net’s quick / smart lookup of functions. Typing http://localhost/phpman/substr takes me to http://localhost/phpman/function.substr.html in a split second.
Jai ho!
Let me jump to the code now that you’ve read so much!
Here’s the .htaccess file. And here’s the PHP file – “manual-lookup.php” placed in the phpman folder. The file is an adaptation from php.net website’s source.
Here’s the complete procedure:
- Ensure you have Apache / PHP setup locally.
- Download the many HTML files version of PHP documentation.
- Extract it in a folder called “phpman” in your website root. You should now be able to see it at
http://localhost/phpman - Download this file, and save it as
.htaccesswithin thephpmanfolder. - Download this file, and save it as
manual-lookup.phpwithin thephpmanfolder. - Try
http://localhost/phpman/substr– it should work if all went well! - Enjoy!
Hope this helps someone like me
Related posts:
- Smart Usability: Remember password, not username “Remember Me” options typically remember both username and passwords. Some...
- Recursively unlock files on Mac OS X I copied some songs from a CD and ended up...
- Fixing bad XML, any recommendations? I am using Text_Diff classes of PHP to generate differences...
- Collaborating in web application using SVN What would you do if you wanted to manage document...

Nice work
Hannes Magnusson
2 Jun 09 at 1:34 pm
Here’s another gem about PHP Manual – a command line utility to lookup PHP.net manual. It requires some work, but is really interesting use of shell scripting! You can easily customize that script to lookup your local setup of php manual as well!
Nirav
2 Jun 09 at 1:54 pm
Btw, you can add new hostnames with IP address 127.0.0.x to etc/hosts and create virtual hosts for them. That way you can get for example
http://phpman/substr
antti
18 Jan 10 at 11:21 pm