Introducing PSR-2 Styling0:00
Very likely, the first thing you will notice when you install Laravel 5.1 is that Laravel now uses PSR-2. Think of that as a coding style guide. So for example, in the Laravel 4 days, well, you'd see the namespace placed up here. You'd see the brace on this same line. If I were to scroll down, and if there was something like an if statement, well, that too would be on its own line. But now, it's a little bit different with PSR-2. And remember, this is a set of conventions that the framework is now following. There's nothing that says you have to follow them.
Auto-Fixing with Tools1:18
Like I said, the brace will go on its own line. The same with your methods. And even better, if you use some kind of build tool, well, you can automatically apply this stuff. That's one advantage to using conventions like this. For example, if I had something like this, well, I have a PSR2 build process. So if I run that, you'll see that it automatically gets fixed. And if you're curious about that, you can just pull in phpcsfixer. And we're not going to go through that full process, I'm sure you can figure it out. But it's basically a simple process of setting up a new build system if you're using Sublime.
Configuring Sublime Build1:48
And we're not going to go through that full process, I'm sure you can figure it out. But it's basically a simple process of setting up a new build system if you're using Sublime Text. And, actually, if we look at that, let me see if I can find it for you, user. And here we go, php.sublimebuild. All we're doing is when we execute it, by default that's Command-B on the Mac, we will trigger this shell script, phpcsfixer, fix the current file that I'm in. That's a variable that Sublime will use, and it just replaces it with whatever file you're currently in. And then, specifically, we want to apply the PSR2 style guide.
PSR-2 Adoption Notes2:21
currently in. And then, specifically, we want to apply the PSR-2 style guide. So yeah, that's all there is to it. Any file in Laravel 5.1 that you look at will have these styles automatically applied. And whether or not you adopt this style guide for your own projects is completely up to you.
