问题
After having installed the HTTP extension from PECL, I expected Zend Studio 6 to recognize the provided HTTP* classes and for code completion to be made available. This is not the case, however. How do I get Zend Studio to recognize classes provided by PHP extensions? Specifcally, I want to be able to use code competition on these classes.
回答1:
I used the phpgenerator.php script from Michael Spector. It generates a php documentation folder with the loaded extensions on your pc. Afterwards the doc path can be added to the Eclipse (Zend Studio) include path. Code Completion works like a charm.
usage:
console: php phpgenerator.php $path_to_doc_output
http://dev.eclipse.org/viewcvs/viewvc.cgi/org.eclipse.pdt/plugins/org.eclipse.php.core/Resources/language/?root=Tools_Project
- This script can be used for generating PHP model for PDT.
- It builds PHP functions according to the loaded extensions in running PHP,
- using complementary information gathered from PHP.net documentation *
- @author Michael Spector
回答2:
In Eclipse, with which Zend Studio shares code, so it might help, is the "PHP Include Path". "PHP Include Path" is in the project explorer. There you can add the directory where the extensions are. Then Eclipse will scan it and you will be able to code-complete.
I did the same with PhpUnit2.
回答3:
I'm not familiar with Eclipse, but if it works in the same way as Netbeans handles PHP extensions, you'll need to add the relevant stub PHP files to the IDE's search path.
回答4:
You can add functions to Studio by putting PHP files with stub function descriptions into special directory. Find this directory in filesystem in a following way: write something like gmdate(), select the name and press F3. You will be taken to one of the prototype files. Note the directory where this file resides (shown on the top and if you hover over the tab). Now you need to create stubs for functions you are missing just like the one you're looking at. You can put them into any file, generally, but I suggest putting them into separate file - like geoip.php - and put this file into that directory. You may also want to do right-click/Show In/PHP Explorer and browse other prototype files if you need examples of how to do it right.
回答5:
Zend ship language support for all the extensions in Zend Studio.
The most efficient way of adding support for language entities provided by unsupported extensions is definitely creating stubs (You can add this support yourself). The description "stub" files for all supported PHP entities can be found in this directory: /.metadata/.plugins/org.eclipse.php.core/language (this is also the location where you should put your stub files).
来源:https://stackoverflow.com/questions/1102205/code-completion-for-php-extensions-in-zend-studio