PHPStorm not seeing include file's variables, unlike DW...


I'm evaluating PHPStorm and have found a significant missing feature.

I've read replies here about it, but I don't think it's correct to say that it's impossible to do.

I'm talking about having a php file with include() function calling another php file.

As in

$categories = get_categories();


Inside product_list.php, the variable $categories is inaccessible! It shows up as being undeclared.

One of the ops here said it's because the page needs to go into run mode in order for the variable to be checked and this become "declared" to PHP.

I find this to not be the case. Dreamweaver CS5 has this feature and it works great! It's called Site Specific Code Hinting.

Here's a screen shot of what I'm talking about:


Is something like this possible in PHPStorm? I really NEED this feature. Thanks. Because one large thing lacking in DW is comprehensive debugging and a lot of other features I like/need from PHPStorm.


Hi Roman,

Marking folder as "source" will not help here -- it does not do anything in PhpStorm.

If you do not mind to type a little bit, you can try adding this kind of code into your included file (product_list.php) -- somewhere on the top:

/** @var $categories array */

/** @var $products array */


This will tell PhpStorm that these variables ($categories and $products) of those types (array) should be available in this file. It's not ideal (from your and Dreamweaver's point of view), but at least something that works.

I'm not using this kind of code myself (or even global variables in general -- most variables are used withing that file scope only, everything else is passed as parameters or via some globally accessible class/object) -- preferring some template engine instead (Smarty/Twig), so this is not a big issue for me. But there are plenty of situations/projects where this natural approach is used, so I'm hoping to see PhpStorm supporting this without extra hints (or more simplified) at some point (most likely (just a thought) going to be optional, as collecting such variables can consume a lot of resources depending on the project size etc).


I have tried marking my project folder as "source" folder. No difference. PHPStorm refuses to look back from linked php files to the originating caller. :(

Nobody finds this useful?


The problem is if you start loading all the variables from includes into the type hinting menu, its going to get redundant and long along with wasting resources for the IDE to load these vars.
Which is most likely what DW does, just scraping anything included and not following any kind of process order.

I see your point in that you would like to see them avalible, but I don't think its worth the trade off of resources and having a full type hint menu of vars from another file.


Thanks for your replies Andrey and Jeff,

I'm glad you see my point Andrey.

I like 98% of the features of PHPStorm. But in this particular category, as well as the split live view/code layout, DW is a lot more natural to use. And remember that DW is NOT a PHP specific tool.

I know that something better can be done in this area. For example Visual Studio 2008 and 2010 ReSharper, which is also by JetBrain, has a feature like this. And lets you view declared variables in other files and in addition, jump to them with ctrl + click.

Also the design I'm using is just plain vanilla MVC layout. That's why I don't put everything in one file, that's the point of MVC, it splits the workings of a site into model-view-controller. So i pass back variable values to my controller from model part, which is the index.php file. I think Joomla engine uses this structure as well.


I understand about what you mean about the resources and all, but today's computers are powerful enough.

At least this should be toggle option, like it is in DW. If your project is so large that it eats up all your RAM, you disable it.


The ctrl + left click on any variable does take you to the declaration within any of the files in your project in PhpStorm, so from that stand point even though the variables are not showing as declared in the file, PhpStorm is tracking things even if it isn't showing you that it is.

I stopped using dreamweaver towards the end of the CS3 life cycle, apparently Adobe is moving away from this and several other individual products and creating an all inclusive one. Dreamweaver will probably be discontinued as a standalone product in 2012.
From a branding standpoint, this new line of product(s) from Adobe is being targeted to businesses so I can imagine the price points for the useful features being above what most individuals and freelancers could afford.  In comes PhpStorm to save the day...

It would be useful if PhpStorm stopped showing variables not being declared that are in other files BUT, it could just be that I include ONE file into all my php files that itself is a list of included files and PhpStorm isn't tracking back far enough... I haven't tested this theory out.   If you ctrl + left click you are taken directly to the declaration of that variable though, if it is defined somewhere else.

I don't really want a long long list of variable hints I have to scroll through but I can see the usefulness of what you are talking about, in a smart hinting code completion sort of way.  I use PsPad a lot too and it has the same kind of code completion that PhpStorm has, it too does not give hints of included files variables and shows undeclared variables from included files, so this is not a restriction to just PhpStorm.  I think what the new Dreamweaver is doing is unique and is trying to please everyone sort of feature that probably comes at a cost of resources.  

I personally can't vote on anything in the trackers because the only thing I can login to is this forum, I contacted support and various other support personal of jetbrains for several months and never got a email or resolution but if you add a tracker to thier tracking system with this feature request I am sure those that can vote will do so, if enough people vote it maybe added in a future release of PhpStorm.  Though everytime I say something like this someone comes in with the answer to check or uncheck a box in settings somewhere..  LOL


Please sign in to leave a comment.