Exceptional Exceptions: Cleverly throwing Exceptions in PHP

TIL, from the Engagor Clarabridge Development Blog: When creating an \Exception in PHP (including your own extended classes), you can pass in a third argument named $previous. It defines the previous \Exception used for exception chaining, leaving you with better errors for debugging: try { $this->doSomeImportantStuffWith($foo); } catch (VeryDescriptiveException $e) { // do some stuff […]

Getting started with Event Sourcing (in Laravel)

I’ve seen Freek give his talk on Event Sourcing in Laravel at a Full Stack Ghent meetup recently. Glad to see the talk evolved a bit more and he now has made a recording of it. Don’t let the “in Laravel” part scare you, as the knowledge is applicable across different frameworks and languages. For […]

Symfony Form Validation: Validating a date range

One of the (Symfony based) PHP projects I’m working on contains a form which allows the user to generate video clips from CCTV footage. To do this the user can enter a start and stop DateTime. For this to work the submitted input data is then checked: both start and stop must be dates, and […]

Selling Composer Packages through “Private Packagist for Vendors”

Nice new addition by Packagist: If you’re selling PHP packages, the easiest way to offer Composer package installation to your customers is now “Private Packagist for Vendors”. You get a unique URL and authentication token for each customer and they can use these in their composer.json file to install your packages. Especially if you’re still […]

Unsafe SQL functions in Laravel

Recently the folks from Spatie released a security update for their laravel-query-builder package. Turns out it was vulnerable to SQL Injection. At the core of the vulnerability is the fact that Laravel offers a shorthand for querying only certain fields of JSON data, but that these do not get escaped when converted to a json_extract […]

bramus/enumeration – A Package to work with Enumerations in PHP

Earlier this week I released a new package on Packagist. It’s a Package to work with Enumerations in PHP, named bramus/enumeration. The package is my own take on Enumerations in PHP, which grew over time. 👨‍💻 Looking back at the code that eventually would form the basis for this package, I can see – thanks […]

php-timecop – A PHP extension providing “time travel” capabilities

Now this looks handy, especially when you’re writing/testing code that’s dependent on the system’s time: php-timecop is a PHP extension providing “time travel” and “time freezing” capabilities Freeze time to a specific point. Travel back to a specific point in time, but allow time to continue moving forward from there. Scale time by a given […]