PHPnews.io

Overview for 'stitcher-io'

Things dependency injection is not about

Written by Stitcher.io / Original link on Jul. 29, 2019

If you're using any modern framework, chances are you're heavily relying on dependency injection. But do you know what dependency injection actually is about — or better: what it's not?# The dependency containerWhile every modern framework ships with a dependency container — a big box that knows ho…


Preloading in PHP 7.4

Written by Stitcher.io / Original link on Jul. 4, 2019

With PHP 7.4, support for preloading was added, a feature that could improve the performance of your code significantly.In a nutshell, this is how it works:In order to preload files, you need to write a custom PHP scriptThis script is executed once on server startupAll preloaded files are available …


Typed properties in PHP 7.4

Written by Stitcher.io / Original link on Jun. 29, 2019

Typed class properties have been added in PHP 7.4 and provide a major improvement to PHP's type system.These changes are fully opt-in and non breaking to previous versions.In this post we'll look at the feature in-depth, but first let's start by summarising the most important points:They are availa…


Tests and types

Written by Stitcher.io / Original link on Jun. 6, 2019

Imagine a simple function: rgbToHex.It takes three arguments, integers between 0 and 255; and converts it to a hexadecimal string.Here's what this function's definition might look like in a dynamic, weakly typed language:rgbToHex(red, green, blue) { // …}I think we all agree that "program correc…


Arrow functions in PHP 7.4

Written by Stitcher.io / Original link on May. 1, 2019

Short closures, also called arrow functions, are a way of writing shorter functions in PHP.This notation is useful when passing closures to functions like array_map or array_filter. This is what they look like:// A collection of Post objects$posts = [/* … */];$ids = array_map(fn($post) => $po…