![]() If you see any errors, or want to say thanks. Let’s focus on writing good code - leave the formatting to the computer. I’m sure pint isn’t going to be as smart about formatting as some people can be - and you might not like all the rules it follows.īut the point surely is to free up developer brainpower for tasks that deliver business value - and to spend code review asking questions like “why have you done it this way?” “have you considered?” and “what if?”.Ĭode reviews can be a really uplifting experience where we feel we have given something good to the project and learned from our peers. I’d recommend fixing all existing formatting issues in one go when this is introduced, then run pint as part of the CI process so that all new code stays formatted as expected. You can get pint to show diff but I find it easier to just make the changes and then look at the diff in git. vendor/bin/pint -test to check for formatting issues ![]() This sounds like another tabs vs spaces discussion.Check the underlying PHP-CS-Fixer configuration for available rules. I don't know if we can discuss whether there should be a single, universal coding style reference. It completely defeats the purpose of standards to ignore them and create your own, especially ones that are industry recognised and collaboratively driven. Sort Tailwind CSS classes (even inside PHP code). It's heavily opinionated, and just assumes some things. RT zepfietje: Support for AlpineJS coming to the laravelphp Blade formatter Format PHP using Laravel Pint. Well, Laravel doesn't force much by default. There is nothing in the documentation that tells users of the framework that they should use specific formatting for their project. They only define common interfaces that should be implemented across the browsers. True, but they don't recommend any particular coding style. The W3C produces recommendations, but it was only when Google, Mozilla and Microsoft started implementing those recommendations, that the internet improved. ![]() It's not formalized, but we could say that Pint is something that does it. I think it derives from the existing coding style adopted by Taylor and other core members. There are no code formatting "rules" in Laravel.īut yes, there's no official doc saying how the code should be formatted in Laravel applications. So yes, it's that classic XKCD cartoon all over again :( It has its own preferences which differ from PSR-12. ![]() The Laravel preset is our own pragmatic way of defining a coding standard. Update: The Laravel team have confirmed that the "laravel" preset is completely bespoke and does not follow PSR-12. (I'd argue, if there's going be a default code style, it should be the industry recognised PSR-12 - which, interestingly enough, was actually the case when Pint was in development.) How many people will read this and think that Pint is "fixing" their code by applying this proprietary "Laravel" code formatting? Pint does not require any configuration and will fix code style issues in your code This is how the documentation describes Pint: and, worse of all, it's enabled by default. Pint is built on top of PHP-CS-Fixer and makes it simple to ensure that your code style stays clean and consistent. It's not developed in collaboration with anyone else. Laravel Pint is an opinionated PHP code style fixer for minimalists. According to the documentation, contributors are expected to follow PSR-2 (the predecessor to PSR-12).Īs stated, there's no documentation for this new coding style. Not even the Laravel project itself uses this new style. We didn't need a new, non-collaborative, non-documented, proprietary formatting style to "fix" it! It has been written through open collaboration over years. PSR-12 is the industry recognised standard for PHP code formatting. ![]() The problem with standards is that they're not standards if industry leaders decide to not follow them, and create their own instead. Thanks for that, Team Laravel.īut what formatting style does it include by default? Why "Laravel" of course. Hurrah, Laravel Pint gives us a nifty way to apply code formatting to a project programmatically. ![]()
0 Comments
Leave a Reply. |