A couple handy features in PHPStorm

Joel Clermont (00:00):
Welcome to No Compromises, a peek into the mind of two old web devs who have seen some things. This is Joel.

Aaron Saray (00:08):
And this is Aaron.

Aaron Saray (00:15):
Every once in a while, it is my joy, my absolute privilege-

Joel Clermont (00:18):
Oh boy.

Aaron Saray (00:19):
... to be able to teach Joel something in a UI tool. Because Joel is really one of those old school guys where he loves to use the command line for everything. And command line has its place but for whatever reason, the way I started programming, I just ended up using GUI tools a lot. So I really love all the stuff that PhpStorm gives us, like its Git integrations, stuff like that.

Joel Clermont (00:45):
Sure.

Aaron Saray (00:45):
But there was one tool the other day that I remember showing you and well, I know you knew it was there, but I just kept almost like, "Just do this already."

Joel Clermont (00:56):
"Just stop with command tapping to your terminal, just use this."

Aaron Saray (01:00):
It was the local history in PhpStorm.

Joel Clermont (01:04):
I remember this, yeah. Because you kind of joked but I learned Git at the command line and I'm comfortable with it. But there are things I'll jump to a UI for, but this was not one of them, right? Sometimes if I had complicated branches and I wanted to look at how things laid out, I might open SourceTree. I think that's the one, Atlassian makes. But yeah, this local history feature to me, why would I use that? Why wouldn't I just use git log? And you made me do it.

Aaron Saray (01:32):
Right. It was interesting because we use branches and branch off on different things sometimes. But there's still intermediate steps between the different commits that you might do and things that you've done just throughout the day. So that's one of the reasons why local history comes in useful because your Git history is, "I did this and I committed that, and now I am at this stage." There's nothing in between, that could be a couple of hours in between there.

Joel Clermont (02:03):
Yeah, that's a good point. The local history, it shows more than the git log does, like more history. If I recall right, the other thing that really excited me about it, you know how excitable I am, was... I'm like, "What are these symbols?" It would also show every time you had run a test whether it passed or failed. Like in this case, I think I was using kind of the more traditional TDD flow or it was a bug, I can't remember exactly. But there was a lot of test runs, fail, fail, fail, fail pass, and we were trying to revert something after arguing about code formatting or something like that. So seeing that, certainly git log doesn't capture every time you ran PHPUnit and what the result was. That was another, I thought, really useful feature in the local history. Even if I didn't care about going back in time, just seeing what tests ran and what passed or failed.

Aaron Saray (02:59):
That's so weird too because when it comes to unit tests, I run my unit tests on the command line and you use the GUI for yours.

Joel Clermont (03:05):
That's right. Yeah, that's true. That's a good point. If you're running PHPUnit at the command line, the PhpStorm local history would not show it. But I was using the UI test runner. Well, I like using the shortcut key so if you're inside a test, it's like Control R or something, they will run the test that your cursor is within. So I like that.

Aaron Saray (03:27):
Yeah, I think the point here though is even if you're not using that it's just kind of nice to have. There's basically a snapshot, if you want to look at it that way, of every time that you save or PhpStorm automatically saves a file. You can kind of look at that and in a perfect world if you're really a complete Git master maybe every single time that you had an idea, you'd make another branch and do your stuff in there, commit it, switch between branches. I think in a perfect world, if we were using the tool to its most extent, you might have 20, 30 different branches throughout the life of this one branch of the different things you've tried and tried to figure out. But we don't do that. You stick on one, maybe two if it's going to be a really long experiment. It's nice to have these little snapshots along the way too that you can look like, "15 minutes ago I was doing something, I changed something, there was a phone call. Then I thought I remembered it but I forgot and I moved on." And you're like, "Wait a second, what was that an hour ago?" and you can look back at that.

Joel Clermont (04:28):
No, that never happens but. I have another PhpStorm feature and you tell me, I don't remember if you showed this one to me or I discovered it in my own greatness. But it has to do with doing pull request reviews, which we both primarily do in the GitHub website, you know right? You just go there and do it. Because it's pretty good, you get syntax highlighting, you get a little bit of context, there are nice things in it. First of all, PhpStorm has a GitHub integration where you can open a pull request and you can see everything. Like, you can see comments, you can reply to comments, you can add comments. But the additional thing it gives you is it has all of the really advanced syntax highlighting and error detection and click-through navigation and all the things that your editor had that maybe someday they'll have in GitHub, but they don't right now.
One example that pops into my mind is an unused namespace import. Like, you can look at that in the code in GitHub and maybe notice it, but maybe the diff was deleting something and now it's not even going to show up in the diff that this namespace import still exists. So you end up with this cruft in your code that doesn't need to be there. But in PhpStorm, you see that and it throws a weak warning on it. It's like, "Hey, we can just click a button and get rid of it." So there's a million things like that. I still don't do it all the time, but if it's a bigger meatier pull request, I do like to pull it into PhpStorm.

Aaron Saray (06:03):
Yeah, I think part of the whole discipline of being a programmer is not getting lost in your tools but understanding them. So when we talk about these things, maybe these are things you've been doing the entire time and you're just like, "Of course guys, let's get with it." Or maybe it's things you never even knew it could do. The point is we try to use... The tool is such a integral part now of the programming experience that we try to learn little bits about the tool in the same way that we're always learning little bits about the language and the libraries and the frameworks as well.

Joel Clermont (06:36):
Right. What I want to dig into a little more is the Docker integration. Like, we use it, for example, running unit tests that'll launch our container, but I know it'll manage your whole Docker Compose and you can start and stop services. That's on my to-do list but like you mentioned, little bits here and there. Don't just blow a whole week fiddling with your different tools.

Aaron Saray (07:02):
So every once in a while there's something that happens that's so embarrassing but it shouldn't be embarrassing. But then it's also weird and embarrassing.

Joel Clermont (07:09):
I'm intrigued.

Aaron Saray (07:11):
That you're just like, "I don't understand, what just happened to all this?"

Joel Clermont (07:14):
Okay.

Aaron Saray (07:14):
So I went to the grocery store the other day and I was buying some stuff and I went through self-checkout and I'm putting in... I bought two jars of pickles, so I put the first one in the bag and I put the second one in the bag and the bag rips and the pickle jar falls out and just smashes. And there's pickle juice all over and glass. Then first of all, you're just like, "Okay, I'm that person that made the glass shatter." You know, everyone's looking at you but also not looking at you?

Joel Clermont (07:44):
That's my worst fear by the way.

Aaron Saray (07:46):
So then you're standing there like, "What do I do?" Like, I don't go to the grocery store carrying around a mop.

Joel Clermont (07:55):
No.

Aaron Saray (07:55):
And I don't want to leave it because that looks like I'm a jerk or whatever, so I'm just like kind of standing there-

Joel Clermont (08:00):
And you paid for it, right? If you put it in the bag, you've paid for it.

Aaron Saray (08:02):
Well, I haven't yet... Yeah, but you know...

Joel Clermont (08:04):
Oh, okay.

Aaron Saray (08:04):
So I'm just standing there and then a girl comes over and she's like, "Oh, hey you know, I'll get it cleaned up and you can just continue." I'm standing by that checkout and she's like, "Oh, you can go get another one." She's like, "Oh, I can take this off your bill." I'm like, "Oh no, it's fine." I should have said yes but now I'm starting to panic because there's this worker that's kneeling down, cleaning up stuff, and I'm still just standing there like a deer in the headlights.

Joel Clermont (08:36):
Were you eating a pickle?

Aaron Saray (08:37):
No. I had some more stuff to do but it's not like I can do it because it's all in front of there and she's looking like, "Oh, well you can just continue what you're doing." I'm like, "I'm not going to check out over the top of you."

Joel Clermont (08:48):
Drop another jar of pickles on her.

Aaron Saray (08:50):
Yeah. So she's cleaning this up and stuff and she's like, "Oh, well, you can go get another one." And at that point I was just like, "I just want to get out of here." Like, I am now to the point where I don't even care if I leave with everything or nothing. I'm just like, "I just want to get out of here." But when she said that, somehow I responded in a way that I've never responded before and I hope I don't again. I looked at her and then I did that thing where you're trying to be quiet but funny. So you put your hand to your mouth and you kind of talk at the side of it. And I go, "I don't need another one, I had two anyway." I was like, "What kind of old person did I just become?"

Joel Clermont (09:29):
Wow.

Aaron Saray (09:29):
Like, that's not funny. You don't have to whisper that. And she's like, "Okay." And I'm just like, "Oh, just get me out of here."

Joel Clermont (09:39):
See, I thought the embarrassing part was dropping the pickles. But you're right, you made it way worse.

Aaron Saray (09:44):
Way, way worse.
There's so many things to learn. And how do you know which ones to focus on and how do you find the time?

Joel Clermont (09:56):
Well, we are full of things to share like that. Head over to masteringlaravel.io and sign up for our free newsletter and we'll send you a short tip each day.

No Compromises, LLC