Search code examples
phpphpstormphp-include

PHP Path Prefixed After Include


I am using the PhpStorm IDE.

I add the include to the PHP file:

include_once 'lib\Zend\Form\Element';

And I am expecting to be able to use it as:

    new Element();

But instead PhpStorm will only let me use it as:

    new \Zend\Form\Element();

How can I use it without the prefixed path?


Solution

  • Apparently it is a difficult task to use any part of Zend without an autoloader, or 10+ lines of config. Difficult in that you must edit the Zend source to include required files there which is a mess, not future proof, and a bad hack.

    Importing and namespacing in my usage file alone does not solve the issue.

    If you have the same problem look into 'composer' and autoloading Zend.