We have moved our forum to GitHub Discussions. For questions about Phalcon v3/v4/v5 you can visit here and for Phalcon v6 here.

PHPStorm Integration problems

Hello !

I've been using PhalconPHP for some time. Before that, in every of my PHP projects, I used the excellent PHPStorm IDE.

As I'm now working with PhalconPHP for most, if not all, my PHP projects, I wanted to have a nice editor with auto-completion & such. I tried several methods found on internet such as: This solution, adding it to the PHP libs path instead of the eclipse one (as I'm not using Eclipse here). or This one, which don't work at all. By that I mean that no tool seems to be included and rendered available. When creating a project, I don't have any choice to select PhalconPHP. Using the console tools don't matter to me as I'm writing almost all my code by hand without any tool but the thing I need is Phalcon code completion. If I try to enter something basic that should give me autocompletion choices such as

use Phal

I have no choice. With 1 less character I have everything for Phar, which is obviously not needed for me. The biggest problem is if I try to enter, for example,

use Phalcon\Di\FactoryDefault;

It'll be marked as nonexistent classpath and everytime I'll use a component from the factorydefault, I'll get an error... How can you integrate PhalconPHP in order to have auto-completion choices working ?

(EDIT: note that by "getting an error" I mean the IDE signals me all the lines as problematic. If I open the page in my browser it works flawlessly)



85.5k
Accepted
answer

download this in a custom location on your hdd https://github.com/phalcon/phalcon-devtools/tree/master/ide/stubs/Phalcon

settings -> Language and frameworks -> php on the right click the + and add the folder where you download the strubs.

Most of things works. Model::find/findFirst is screwed in the latest realese you can try an earlier one.

class test {
    public $koko = 1;
}

$di->set("test", new Test());

$class = $this->getDI()->get("test");

$class-> // this will NOT work also

Thank you !

I removed my other copy of the phalcon-devtools and re-downloaded PHPStorm to make sure I started from a clean version and everything works nicely !

Even if the Model::Find/* isn't working, I don't really mind as I don't use models for now because I can't manage to use them properly and raw SQL queries using the PDO interface is nicer for myself for now.

I do the following to get code completion working in PHPstorm from objects loaded from DI.


/** @var \MyNs\MyClass $myClass **/
$myClass  = $this->getDI()->get("myClass");

download this in a custom location on your hdd https://github.com/phalcon/phalcon-devtools/tree/master/ide/stubs/Phalcon

settings -> Language and frameworks -> php on the right click the + and add the folder where you download the strubs.

Most of things works. Model::find/findFirst is screwed in the latest realese you can try an earlier one.

class test {
  public $koko = 1;
}

$di->set("test", new Test());

$class = $this->getDI()->get("test");

$class-> // this will NOT work also