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 …

Laravel Backup

If you’re a developer using Laravel I’d strongly recommend “Laravel Backup”, a package developed by the folks over at Spatie. Version 3 just got released: Laraval Backup can backup the files and databases of your application to one or more external filesystems. It uses Laravel’s native cloud filesystem to do this. The package can also …

Typed Arrays in PHP

Tim Bezhashvyly: Typed arrays exist in PHP, at least to some degree. This wonderful feature sneaked in as a side-effect of variadic functions that were added to the language in PHP 5.6. Turns out one can actually typehint the variadic parameter, as so: <?php function foo (Product …$products) { /* … */ } Only works …

Scrapbook, PHP Caching Environment

// create \Memcached object pointing to your Memcached server $client = new \Memcached(); $client->addServer(‘localhost’, 11211); // create Scrapbook cache object $cache = new \MatthiasMullie\Scrapbook\Adapters\Memcached($client); // set a value $cache->set(‘key’, ‘value’); // returns true // get a value $cache->get(‘key’); // returns ‘value’ Scrapbook is a caching environment for PHP. The cornerstone is key-value-store, which sets a …