PHP Insights – Analyze the Code Quality of your PHP Projects

PHP Insights is a Static Analysis Tool for your PHP code. It contains built-in checks for making code reliable, loosely coupled, simple, and clean. Works out-of-the-box with the current set of popular frameworks. # First, install: composer require nunomaduro/phpinsights –dev # Then, use it: ./vendor/bin/phpinsights PHP Insights →

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 …

Bash/Shell Autocompletion for Composer

The other day I opened up a PHP project that I hadn’t worked on in a while. No longer remembering which Composer Scripts I had defined for it, I needed to take a peek inside composer.json to see which ones were available to me. Then it hit me: why is there no autocompletion for composer …

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 …