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 […]

Cauditor – PHP Code Audit and Visualisations

Great tool by Matthias Mullie, to analyzing your PHP code (in the screenshot above you can see the analysis of ansi-php): Figure out complexity hotspots in the blink of an eye from a couple of very simple charts [generated by Cauditor]. The charts will help you understand the architecture of the project & make it […]

PHP HTTP Public-Key-Pinning Builder

HTTP Public-Key-Pinning Builder aims to make it easy to build HTTP Public-Key-Pinning headers in your PHP projects. As so: <?php use \ParagonIE\HPKPBuilder\HPKPBuilder; $hpkp = HPKPBuilder::fromFile('/path/to/source.json'); $hpkp->sendHPKPHeader(); { "hashes": [ { "algo": "sha256", "hash": "hwGEkxDWJ2oHtKv6lsvylKvhotXAAZQR1e0nq0eb2Vw=" }, { "algo": "sha256", "hash": "0jum0Eiu4Eg6vjn3zTmyd/RobfN6e4EagFQcz6E5ZKI=" } ], "include-subdomains": false, "max-age": 5184000, "report-only": false, "report-uri": null } HTTP Public-Key-Pinning Builder →HTTP […]

Image diffing using PHP

PHP package by Undemanding to calculate how much difference (in percent) there is between two images: use Undemanding\Difference\Image; use Undemanding\Difference\Method\EuclideanDistance; $image1 = new Image("/path/to/image1.png"); $image2 = new Image("/path/to/image2.png"); $difference = $image1->difference($image2, new EuclideanDistance()); $boundary = $difference->boundary(); // → ["left" => …, "top" => …] $percentage = $difference->percentage(); // → 14.03… Undemanding Difference → Did you […]

Easily interact with Google Calendar from PHP with spatie/laravel-google-calendar

Great new package by spatie: use Spatie\GoogleCalendar\Event; //create a new event $event = new Event; $event->name = 'A new event'; $event->startDateTime = Carbon\Carbon::now(); $event->endDateTime = Carbon\Carbon::now()->addHour(); $event->save(); // get all future events on a calendar $events = Event::get(); $firstEvent = $events->first(); $firstEvent->name = 'updated name'; $firstEvent->save(); // create a new event Event::create([ 'name' => 'A […]

Simple PHP Valuestore Class

If you’re looking for a simple Value Store (you know: key-value) Freek and Jolita over at spatie has whipped up a simple class that does this for you. $valuestore = Valuestore::make($pathToFile); $valuestore->put('key', 'value'); $valuestore->get('key'); // Returns 'value' $valuestore->has('key'); // Returns true // Specify a default value for when the specified key does not exist $valuestore->get('non […]