Adding new extensions to Zend Studio

I am using Zend Studio for my everyday PHP work, and I like it. I know many others do too, or use PDT. It has one very cool – though not widely known – feature that allows you you to add unknown extensions to code completion. I.e., if you have some extension, create stub file with PHPDOC descriptions – i.e. something like this:

/**
 * Do stuff
 * @param string $arg
 * @return array
 */
 function dostuff($arg) {}

for each extension function, Studio will know to pick it up. You can put this file into Studio’s prototypes directory – easiest way to find it is just write something like chdir() anywhere, select the name and press F3, the directory of the file that you’ll get is the one you need.

However, the problem is how to create this file. E.g., I’m doing some work with MongoDB lately, and PHP has great Mongo extension – which Studio doesn’t know yet. So how do I create those stubs? Obviously, I am too lazy to manually write them. I went to look for a tool that would allow me to make one – and found none. At least not in 15 minutes I spent looking, so I decided to write my own.

What came out is the Reflector. It uses PHP reflection and PHP’s manual XML sources in order to generate stub file (see example mongo.php on git to check what comes out). Right now it’s not very smart and handles only classes/methods, not functions (probably will fix that soon), but maybe it will be useful to somebody.

Or maybe somebody points me to a tool that does that even better in comments :)

Update: Roy Ganor (who is leading the Zend Studio project) in comments pointed me to the source of the Studio generator script. It will generate stubs for all extensions you have, as I can see. Try it out. Thanks, Roy!

About these ads

10 thoughts on “Adding new extensions to Zend Studio

  1. The generator link appears to be out of date due to eclipse moving from cvs to git. Is there an updated link? thanks.

  2. Hi:

    I have tried the generate.php script, but I can’t get anything generated :(

    Here is the output I got:


    PHP Notice: Undefined variable: functionsDoc in /var/www/SolrTest/generate.php on line 256
    PHP Stack trace:
    PHP 1. {main}() /var/www/SolrTest/generate.php:0
    PHP 2. parse_phpdoc_functions() /var/www/SolrTest/generate.php:45
    PHP Notice: Undefined variable: classesDoc in /var/www/SolrTest/generate.php on line 352
    PHP Stack trace:
    PHP 1. {main}() /var/www/SolrTest/generate.php:0
    PHP 2. parse_phpdoc_classes() /var/www/SolrTest/generate.php:46
    PHP Notice: Undefined variable: constantsDoc in /var/www/SolrTest/generate.php on line 385
    PHP Stack trace:
    PHP 1. {main}() /var/www/SolrTest/generate.php:0
    PHP 2. parse_phpdoc_constants() /var/www/SolrTest/generate.php:47
    PHP Notice: Undefined index: internal in /var/www/SolrTest/generate.php on line 88
    PHP Stack trace:
    PHP 1. {main}() /var/www/SolrTest/generate.php:0

    I run using the following command:

    php generate.php -split ~/Downloads/docs/
    

    Thanks!

  3. Thanks, I’d been wondering about something like this, also through working with MongoDB lately.

    I wouldn’t encourage people to click on shortened URLs in blog comments, though. What’s wrong with the real URL?

    • Your script is much more advanced, but I see the idea is the same. Maybe you could ship it with Studio? :)
      The recipe for adding stubs I found on Zend forums, but generator script was not mentioned anywhere. I think I’ll add an update.

      • Yea, it was a good time… The bad thing is that PHP documentation doesn’t have a specification, that’s why this script is a bit ugly :-)

Comments are closed.