PHP - Code Style, PSR 2 Standard

In this video, we will see what code style guides are (specifically PSR-1 and PSR-2), why it is good to follow these standards, and how we can apply them automatically thanks to the PhpStorm IDE. While this could be the first thing to do when arriving at a project that does not follow these guidelines, it could be the second step after applying a correct namespace as we saw in the previous video.

Topics covered

  • What it is and why it is important to follow the PSR-2 code style standard
  • How to configure PhpStorm to automate code formatting following PSR2
  • Inspection for traditional array syntax
  • Important: The video does not mention some of the very interesting resources listed in the "Related Material" section of this post. I recommend checking them out :)

Video

Index

  • 0:00 - Introduction
  • 0:33 - Configuring PhpStorm with PSR-2 code style
    PSR2 PhpStorm Code Style
  • 1:09 - Why it is good to follow the PSR-2 standard
  • 2:40 - Applying style guides automatically
  • 4:00 - Manual process altering overlooked details
  • 4:58 - Error for not specifying the full namespace of a class. Why to specify this through "use" and not in each class
  • 5:40 - Adding inspection for traditional array syntax
    Array syntax inspection
  • 7:05 - Commit with style changes

Related Material

Upcoming videos

Pay according to your needs

lite (only monthly)

19 €
per month
  • Access to a subset of courses to lay the foundation for maintainable, scalable, and testable code
  • Company invoice
PopularLaunch Week

standard

20,75 €
Save 171
Annual payment of 249
per month
  • Full course catalog
  • Receive job offers verified by Codely
  • Company invoice
Launch Week

premium

37,42 €
Save 139
Annual payment of 449
per month
  • All previous benefits
  • Early access to new courses
  • Discount on workshops

We won't increase the price while your subscription is active