PSR-20 Clocks: Testable Time in PHP
– doeken.org - submitted by Doeke Norg
Learn how a ClockInterface helps you decouple time and write stable, testable code. It's about time!
Read more [doeken.org]
Posts tagged with psr
– doeken.org - submitted by Doeke Norg
Learn how a ClockInterface helps you decouple time and write stable, testable code. It's about time!
Read more [doeken.org]
Matthias Noback shares some considerations on when you could rely on PSR abstractions
Read more [matthiasnoback.nl]
Join 9,500+ smart developers
Get my monthly newsletter with what I learn from running Spatie, building Oh Dear, and maintaining 300+ open source packages. Practical takes on Laravel, PHP, and AI that you can actually use.
"Always fresh, useful tips and articles. Carefully selected community content. My favorite newsletter, which I look forward to every time."
No spam. Unsubscribe anytime. You can also follow me on X.
Phil Sturgeon provides a good explanation on the why and how of middlewares in PHP.
Recently there has been a lot of buzz about HTTP middleware in PHP. Since PSR-7 was accepted, everyone and their friend Sherly has been knocking out middleware implementations, some of them stunning, some of them half-arsed, and some of them rolled into existing frameworks. HTTP Middleware is a wonderful thing, but the PHP-FIG is working on a specific standard for middleware, which will standardise this mess of implementations, but some folks don't seem to think that would be useful.Let's look into middleware a little closer, to show you why it's something to smile about.
https://philsturgeon.uk/2016/05/31/why-care-about-php-middleware/
It is known by now that every codebase large enough (in terms of lines of code or people collaborating to it) should follow any code standard. Here at Coolblue we weren’t different and were using our own coding standard.http://devblog.coolblue.nl/tech/converting-big-php-codebases-to-psr2/But codebases evolve. And our codebase – that has been supporting one of the most visited ecommerces in The Netherlands – needed to be upgraded to a coding standard that’s a little bit more up to date.
This is the process we follow to move into PSR-2.
In the past months we converted several of our old projects to PSR-2 with Fabien Potencier's coding standards fixer and had zero issues doing so. Hurray for standardized code.
Beau Simensen gave a good overview of PSR-7 at the recent PHP North West conference.
https://www.youtube.com/watch?v=iZhcM0NH6J8
One of the most important endeavors in the PHP universe is the PHP Framework Interop group. The group consists of several maintainers of big PHP projects. Their aim is to find commonalities between their projects and find ways to work together. They do this by proposing and accepting PSR's, short for PHP Standard Recommendation.
One of the most important PSR's is PSR-4 (and the now deprecated PSR-0) which describes a way to autoload classes. Thanks to this standard packages can be easily be reused in many frameworks and projects. PSR-2 is another important one. It is a coding style guide and greatly improves readabiltiy of code when working with a bunch of developers. There are several other PSR's that have been accepted.
Today PHP-FIG published their new site. It features a beautiful design by Jonathan Reinink (he's the designer of the PHP League sites, author of Glide, and creator of the PHP Package checklist). If you use PHP in any way you owe it to yourself to check it out the new site.
One thing frameworks have been providing for many years is HTTP message abstraction. PSR-7 aims to provide a common set of interfaces so that frameworks can use the same set of abstractions. This will enable developers to write re-usable, framework-agnostic web components that frameworks can consume.https://mwop.net/blog/2015-01-26-psr-7-by-example.html