در حال بارگذاری ...

Using Class IntelliSense0:00

All right, so take a look. We created this foobar example file in the last episode. I'm going to add a method here called name, just a dummy method here. Next, I want to use it. So I will switch to FoobarController, and yeah, maybe like right here, I will type in foobar, and because we have that IntelliFence package installed, it will automatically use it at the top, which is great, an enormous benefit. So let's do that, and then we will call that method. Okay, great. So now, let's close this out. I can command click anywhere to instantly browse to that underlying file, or for the method, command click, and it will take me here as well. But now sometimes you're starting with a method, and you're thinking, especially for larger projects, I don't think anywhere in my system is this used, but it's kind of difficult to determine that. You end up doing a system-wide search, and if you don't have tests to back everything up,

Finding All References0:45

I don't think anywhere in my system is this used, but it's kind of difficult to determine that. You end up doing a system-wide search, and if you don't have tests to back everything up, sometimes it's a little precarious to delete that method. But anyways, here I can right click, and because we have IntelliFence installed, we have a very good implementation of findAllReferences. So if we take a look at that, sure enough, we can see, okay, FoobarController is making use of this class in this method. So we can take a look at that there. Ah, okay, it's being called here, so I'm going to keep this method because it's still necessary, and I'll hit escape to close that out. Or another thing we can do is if we go back to FoobarController, sometimes you just want to peek to see how this works. So I can right click and choose peek, or use the shortcut here, and now we can see. Like, yeah, if you ever want to figure out, well, what is the correct

Peeking at Definitions1:26

just want to peek to see how this works. So I can right click and choose peek, or use the shortcut here, and now we can see. Like, yeah, if you ever want to figure out, well, what is the correct argument order, or what actually happens when I call this method, this is a nice way to quickly pop open the underlying code. I first saw this in the brackets editor a number of years ago for peeking at underlying CSS, but it's nice that we now have this on the PHP level as well. So I'll hit escape to close that out, and of course, we can also do this at the class level, or even at the use level. Incredibly useful. Now, what else? Well, what if we didn't have request being used up here, and maybe right here, let's update this, you have the long form, so Illuminate\Http\Request. Okay, sometimes you want to say, I want to condense that down, so I want to use this at the top and bring this back to request. Once again, I can right click,

Adding Use Declarations2:12

so Illuminate\Http\Request. Okay, sometimes you want to say, I want to condense that down, so I want to use this at the top and bring this back to request. Once again, I can right click, add use declaration, I can skip an alias, and there you go. So yeah, this is the sort of functionality you might get from phpStorm, but now it's in code. So let's do that one more time together just to make sure it's perfectly clear. So if we have app\Foobar, and I want to condense this down, once again, we can add use declaration, and we're good to go. Or once again, as a recap, don't forget, if you just type it out normally, it will do that on the fly for you. Great, so we'll keep tweaking our php workflow in the next episode.

دوست دارید گاهی خبرهای Laracasts را ایمیل کنیم؟