gstreamer0.10-ffmpeg
gstreamer0.10-plugins-good
packages.
I just hate seeing developers click manually into their directory tree to search for things. Most projects are too big to be opening files like this. Really, you want to have your hands off your mouse as often as possible.
Time to introduce you to some new best friend shortcuts for navigating! In fact, PHPStorm thinks they're so important that they even have some of these listed front and center when you don't have any files open.
Click the navigate menu at the top. The first option in the list is "Navigate to Class". Its shortcut is command+O
. Knowing that I want to get into the MovieType
class, I'll hit command+O
, start typing the name and boom, I've got that open with just my keyboard.
Need to open a file, like config.yml? Well you're in luck, just use command+shift+O
, start typing the file name in the search box and there it is. We could even look up this bootstrap_3_layout
thing here. Use command+shift+O
again, type the file name, and we can see where it is in the project.
Great! In this case we can see how deep that structure is for this particular file, it's way down in Symfony. If I saw you navigating here manually, I'd be tempted send Samuel L Jackson to your office to tip over your chair. He'd arrive before you navigated there.
And what's really cool - other than not being tipped over by Sam - is that we can use the navigation tree on top to actually click and look around inside of these deep directories.If we really wanted to, we could move the tree on the left all the way to that specific spot by double clicking that directory name at the top. And now we're there and can look around and see what other interesting stuff is hiding here.
The next shortcut on the list up there is "Symbol", which is command+alt+O
. Symbol is referring basically to function names. So here we can look for something like the buildForm
method from inside of my MovieType
. And now it's showing me all of the instances in the project where buildForm
is used. I'll pick the top one and it takes me straight there.
Inside of my controller I call createForm
. So back to command+alt+O
, type createForm
, and there is the one inside of the base Controller
class we extend. This is the function I am calling when I say $this->createForm()
from inside MovieController
.
In this case, if I wanted to know exactly where this createForm()
function lives, I would just hold command and click into it -- so don't forget about that shortcut as well. We can do the same thing here for handleRequest
if we needed to know where that is. Clicking that will take us right into this core Symfony spot and again we can look around inside of here and double click the tree to move us here.
Most of the time, you might be interested in the shortcut command+E
: this will pop up a list of your recent files. Just start typing the name of the file you're looking for until it appears in the results.
Once you have some tabs open, you'll see me do this a lot: my cursor will stay in place while I hold command+shift+[
and command+shift+]
to move around the open files. I use this constantly to jump around from one file to the next.
Okay, the last shortcut I'm going to show you for finding things in your project is easy to remember: shift+shift
. Hitting shift twice will open up a feature called 'search everywhere'. This is a bunch of searches put together, where you can start typing MovieController
and find that, or buildForm
and it will find that for you. Or you can even find CSS tags. In one of the core Symfony files, there's a CSS snippet called .block-exception
. And there it is in our list of results. And clicking on it takes you straight to that file deep inside of Symfony.
There are a lot of ways to move around your project, but the biggest ones to remember are command+O
and command+shift+O
. Or put them together, with shift+shift
.
Ya! We're working way faster.
I used to get obsessed with editors that had a good tree. It's almost embarrassing how much better PhpStorm is than all the old stuff I used to use :)
I believe doing everything that you possible can with a keyboard will significantly improve your coding speed, not just in PhpStorm, but in general. Concerning PhpStorm, there is so much more you can do. Check your keymap, make your own shortcuts and try holding 'alt' every now and then to see what options there are in your navigation. For example, I often find myself needing to replace all variables named "variableX" in a file. Click Ctrl+r to find and replace. type in "variableX". then TAB, then type your new value and then "alt+a" to replace all in your file or selection. This is just a simple example, but there is so much more. Also when selecting code or code blocks, there are always shortcuts! Learn these and you will drastically improve your speed (also, using your mouse a lot can be painful). In conclusion, I think it might be time for an extended and new version of this lesson, there are so many awesome shortcuts, also in combination with the Symfony plugin.
Hey DF,
Yeah, totally agree! Thanks for sharing some tips in your comment. I'd just add that shortcuts might be different on different platforms, but learning them (at least basic you may use every day) would be a great idea.
Cheers!
I love PHPStorm since 3 years now. To see *where* the actual file is located in the directory I like to enable "Autoscroll from source" in the Project-window settings.
And to jump back and forth between the last Navigation-points there is Cmd-Alt-LeftArrow/RightArrow (PC: Strg-Alt-...).
[and there are even more shortcuts...] Thanks JetBrains !
When doing a navigation course it's *REALLY* important not to *just* spout out key chords as (a) they change over time and (b) they are not consistent over platforms. Please always show, in addition, the actual command in the menu system. Thanks!
You're right - and there are so many keymap combinations (more than 10!) for PhpStorm! I tried to show the menu option when that exists, but it doesn't always exist. A lot, but not all of them, are shown on this page - https://www.jetbrains.com/h... - and you can switch between the Keymap in the upper right corner.
Hope that helps!
// composer.json
{
"require": {
"php": ">=5.3.9, <7.3.0",
"symfony/symfony": "2.8.*", // v2.8.15
"doctrine/orm": "^2.4.8", // v2.4.8
"doctrine/dbal": "<2.5", // v2.4.5
"doctrine/doctrine-bundle": "~1.4", // 1.6.4
"symfony/assetic-bundle": "~2.3", // v2.8.1
"symfony/swiftmailer-bundle": "~2.3,>=2.3.10", // v2.4.2
"symfony/monolog-bundle": "^3.0.2", // v3.0.2
"sensio/distribution-bundle": "~5.0", // v5.0.17
"sensio/framework-extra-bundle": "^3.0.2", // v3.0.18
"incenteev/composer-parameter-handler": "~2.0" // v2.1.2
},
"require-dev": {
"sensio/generator-bundle": "~3.0", // v3.1.2
"symfony/phpunit-bridge": "~2.7" // v2.8.15
}
}
Your opening line sums up so much of my own experience. It used to drive me crazy. Your brain is "in the zone" and slow tree navigation totally ruins it. Hence I once stayed up all night and implemented a fast class browser which took you from usage to definition to htmldoc etc in our own proprietary development system. PHP storm does it great. SO much better than ctags, global etc I was used to in Emacs.