Using PhpStorm w/CakePHP: Can't get navigation to Class to work

Consider the following code in a .ctp file in CakePHP:

<td><?php echo h($publication['Publication']['publication_id']); ?> </td>
        <td><?php echo h($publication['Publication']['publication_name']); ?> </td>
        <td >

When I use Netbeans and hover over the 'h' function and click Navigate->Go to Declaration, this elicits a new window bringing up the detail code in that particular controller.

I thought that PhpStorm did the same thing by hovering and pressing the command-B (on Mac).  Apparently this does nothing.  I have gone in and added .ctp to the PHP list of file types but still no joy.

Can someone guide me to being able to xref these classes?  It' hate to think that I can't do this in PhpStorm(costing $200)  and you can in Netbeans (costing $0)!

Thanks!

10 comments
Comment actions Permalink

Hi there,

I'm not a CakePHP user, at all. I do not know what that h() function does, how it is declared and where it is located (if it's part of framework). I may only say that navigation works just fine in PHP files.

Therefore:

1) Please show a screenshot of such file -- maybe h() is highlighted in some way which tells that IDE does not know what that function is (for whatever reason).

2) Please try "File | Invalidate Caches..." in case there were some glitches since previous version upgrade or non-clean shutdown

3) If nothing -- would be good if you provide some very basic standalone project that can reproduce the issue (basically, a framework + those few extra files) so that I can try it here on my computer (zip whole project folder and attach here).

0
Comment actions Permalink

OK so the first image here shows the view.ctp in a Netbeans IDE. I have placed the cursor over the function h, and right clicked. Then I choose Navigate and then Go To Declaration.

Screen Shot 2014-09-09 at 4.03.28 PM.png
Once I do that, then NetBeans editor seems to know that function h is in a program called basics.php and then loads it up and highlights it:

Screen Shot 2014-09-09 at 4.04.20 PM.png
Hopefully this helps. I just want to do the same thing in PhpStorm.

Thanks!

0
Comment actions Permalink

It's all fantastic .. but I need info from PhpStorm and not Netbeans.

0
Comment actions Permalink

There's no information to give. If you perform the same thing in PhpStorm, nothing happens. Absolutely nothing.

If there is something specific you want, I'll try to provide it.

Thanks!

0
Comment actions Permalink

OK Here's what you start with Netbeans. The code is view.ctp.  The ctp is a cakePHP template file. I indicated in NetBeans that the ctp file acts like a php file. Then I simply hovered over the h function (see the <?php echo h), and right clicked. This gives me the Navigate and I choose Go To Declaration


When I click that option the IDE loads basics.php from the system. Note that it opens that in a separate window. I hope this helps.  I'd like to get PhpStorm to do the same thing when I hit command-B.  As you can see command-B is the shortcut for NetBeans, too.

0
Comment actions Permalink

OK Here's what you start with Netbeans. The code is view.ctp.  The ctp is a cakePHP template file. I indicated in NetBeans that the ctp file acts like a php file. Then I simply hovered over the h function (see the <?php echo h), and right clicked. This gives me the Navigate and I choose Go To Declaration


When I click that option the IDE loads basics.php from the system. Note that it opens that in a separate window. I hope this helps.  I'd like to get PhpStorm to do the same thing when I hit command-B.  As you can see command-B is the shortcut for NetBeans, t

0
Comment actions Permalink

OK Here's what you start with Netbeans. The code is view.ctp.  The ctp is a cakePHP template file. I indicated in NetBeans that the ctp file acts like a php file. Then I simply hovered over the h function (see the <?php echo h), and right clicked. This gives me the Navigate and I choose Go To Declaration


When I click that option the IDE loads basics.php from the system. Note that it opens that in a separate window. I hope this helps.  I'd like to get PhpStorm to do the same thing when I hit command-B.  As you can see command-B is the shortcut for NetBeans, t

0
Comment actions Permalink

OK Here's what you start with Netbeans. The code is view.ctp.  The ctp is a cakePHP template file. I indicated in NetBeans that the ctp file acts like a php file. Then I simply hovered over the h function (see the <?php echo h), and right clicked. This gives me the Navigate and I choose Go To Declaration


When I click that option the IDE loads basics.php from the system. Note that it opens that in a separate window. I hope this helps.  I'd like to get PhpStorm to do the same thing when I hit command-B.  As you can see command-B is the shortcut for NetBeans, t

0
Comment actions Permalink
There's no information to give.

Really?

You can start with providing a screenshot of how that *.ctp page (especially the place where h() function is used) looks in PhpStorm. Because I would like to see the same what you see there on your screen.

If you perform the same thing in PhpStorm, nothing happens. Absolutely nothing.

Well ... here is the difference -- it works just fine here.

  • I went to http://www.cakephp.org/ and downloaded latest 2.5.4 version (since you were unable to provide sample test project)
  • Unzipped and opened that folder in PhpStorm v8 EAP build 138.2071
  • Assigned *.ctp pattern to "PHP files"
  • Opened app/View/Layouts/error.ctp file
  • Changed line #24 to be
    <?php echo h($cakeDescription); ?>
  • Now I Ctrl+Click on h (another shortcut for (Navigate | Declaration...)) .. and IDE took me to h() function definition in lib/Cake/basics.php file (line 171) which was opened in new tab.


screen01.png

screen02.png

My suggestions:

  • (repeating this one, since you have not mentioned if you did this or not) -- Please try "File | Invalidate Caches..." and restart in case you have not tried it yet
  • Disable any 3rd party (not bundled by default) plugins and see if this will make any difference
0
Comment actions Permalink

Thanks! I will try that in my version, though I have 7.1.3.
Here is what it looks like in PhpStorm:

Screen Shot 2014-09-09 at 6.41.47 PM.png
Indeed on the Mac it's a Command-Click and that does do exactly what Netbeans does...it opens the basics.php file.  I just haven't seen that shortcut before.

Perfect! Thank you!

0

Please sign in to leave a comment.