Undefined namespaces when using autoload.php with Thrift / PHPCassa

Apologies if this has been asked elsewhere, but I couldn't find it.  If so, please point me in the right direction.

We are currently writing a PHP app that makes use of Thrift and PHPCassa.  Until now, we've been using various text editors and just recently moved to PHPStorm.  While we like what we see in PHPStorm, we're having challenges getting PHPStorm to understand the autoload.php file that comes with PHPCassa.  It's an endless stream of undefined namespace and undefined class errors in the IDE, but the code runs just fine.

Is there something we can do so that PHPStorm understands the autoloader, or do we have to disable the code checking (which would make me sad)?  If we have to disable it, how do we do so?

I attached our autoload.php in case it makes a difference.


1 comment
Comment actions Permalink

Hi Grady,

PhpStorm does not care how your autoloader works -- it recognizes classes purely by their names/FQN.

First of all -- those namespaces/classes -- are they come as PHP C extension .. or they are actually written in PHP?

If it's C extension -- you will have teach IDE about those classes by using some stub file (PHP version of those classes/functions -- just a declaration part, no actual code). You will either have to find already made one .. or create one yourself. All classes/functions that PhpStorm supports by default is done this way -- just write some standard PHP class name and Ctrl+Click on it (for example:. on SplFileInfo) -- IDE will take you to it's declaration (stub file).

If it's written in PHP --- then IDE will know about those classes by parsing them as any other PHP code. If it's well documented (using PHPDoc comments) it should work just fine in vast majority of cases. If it does not -- please provide more details.


Please sign in to leave a comment.