Snapshot testing with PHPUnit

use Spatie\Snapshots\MatchesSnapshots; class OrderTest { use MatchesSnapshot; class test_it_casts_to_json() { $orderId = new Order(1); $this->assertMatchesJsonSnapshot($order->toJson()); } } Again great work by the folks at Spatie: The difference between a classic assertEquals and an assertMatchesSnapshot is that you don’t write the expectation yourself when snapshot testing. When a snapshot assertion happens for the first time, it […]

Easily manipulate images in PHP with spatie/image

Great new package by the folks at Spatie to working with images in PHP, powered by Glide. Glide itself is great, but uses an URL based approach (which has its benefits); yet in most cases I find myself using a code based approach. This is where spatie/image comes into play: spatie/image wraps up Glide so […]

Facebook Live Reactions

Facebook Live Reactions is a Linux script for creating Facebook Live Streams that contains interactive reaction counts. It also includes an interactive shoutout feature that gives live shoutouts to users who typed “shared” into the comment box. The livestreaming itself is handled through ffmpeg; whilst PHP takes care of the counting of all reactions and […]

Getting ready for PHP 7.1

In short: Catching multiple exception types Curl HTTP/2 server push support Support class constant visibility Void return types Generalize support of negative string offsets Allow specifying keys in list() and square bracket syntax for array destructuring Warn about invalid strings in arithmetic Deprecate and remove mcrypt() Upcoming changes in PHP 7.1 → Don’t forget about […]

Minify: A JavaScript and CSS Minifier Written in PHP

MatthiasMullie\Minify is a JavaScript and CSS Minifier written in PHP. Usage is straightforward: use MatthiasMullie\Minify; $sourcePath = '/path/to/source/css/file.css'; $minifier = new Minify\CSS($sourcePath); // we can even add another file, they'll then be // joined in 1 output file $sourcePath2 = '/path/to/second/source/css/file.css'; $minifier->add($sourcePath2); // or we can just add plain CSS $css = 'body { color: […]

Validating SSL certificates with PHP

Great stuff again by Freek Murze from Spatie: A PHP class to easily check the validity of an SSL Certificate. Easily? Yes, easily: $certificate = SslCertificate::createForHostName(‘spatie.be’); $certificate->getIssuer(); // returns “Let’s Encrypt Authority X3” $certificate->isValid(); // returns true if the certificate is currently valid $certificate->isValid(domain.com); // returns true if the certificate is currently valid for the […]