Macroable – A Trait to Dynamically add Methods to a PHP Class
New package by the folks from Spatie: We recently released our newest package called macroable. It contains a trait that, when applied to class, can dynamically add methods to that class. This trait...
View ArticleBrowsershot: Convert a webpage to an image or PDF using headless Chrome
The folks over at Spatie have just release Browsershot v3: Browsershot is a PHP package which can convert a webpage to an image or pdf. The conversion is done behind the scenes by Puppeteer which...
View ArticlePHP Session Locking: How to Prevent Blocking Requests
Today I learned about “PHP Session Locking”: PHP writes its session data to a file by default. When a request is made to a PHP script that starts the session (session_start()), this session file is...
View ArticleEasily set Content Security Policy headers in Laravel with laravel-csp
Speaking of Content Security Policy, the folks at Spatie – who else? – have created a Laravel Package to easily take care or your CSP needs in a Laravel-based app. Even without knowing the inner...
View ArticleIoC containers beyond constructor injection
Talk by Hannes Van De Vreken, as given at the recent phpCE conference in Poland: Did you know your IoC container can do a whole lot more than just constructor injection? Besides that it is actually...
View ArticleDestructuring arrays in PHP: Practical examples
Being more focussed on JavaScript nowadays, I kinda forgot that it’s possible to destructure arrays in PHP ever since the release of PHP 7.1. Frank de Jonge provides us with some practical examples...
View ArticleSwitching PHP versions with Laravel Valet
Switching to a PHP version lower van 7.1 with Valet 2.0 won’t work at the time of writing, as Valet 2.0 does not work with PHP < 7.1 until this issue is resolved. For some older projects that I...
View Article30 seconds of PHP code
A curated collection of useful PHP snippets that you can understand in 30 seconds or less. These functions – like endsWith and startsWith for strings – should be part of the PHP core. 30 seconds of...
View ArticleSwoole – PHP asynchronous programming framework
Swoole is an high-performance network framework using an event-driven, asynchronous, non-blocking I/O model which makes it scalable and efficient. It is written in C language without 3rd party...
View Article★ Missing ~/.valet folder?
Earlier today I updated my Valet installation from version 2.0.x to 2.1.1. To my surprise the ~/.valet/ folder had gone missing, immediately making me think the update process somehow had gone wrong...
View Article★ Fixing the valet share 301 Redirect Loop
One of the nice things of Laravel Valet is that it includes an easy way to make your local site available publicly. For this it has the aforementioned Ngrok built-in. To use it, just run the valet...
View ArticleWhat’s new in the upcoming PHP 7.4?
Good overview by Brendt on the new features that will be landing in PHP 7.4, which is due somewhere December 2019. I’m especially looking forward to Typed properties. New in PHP 7.4 → One thing I...
View ArticleSpeeding up Your PHPUnit tests
Some nice tips by Tim MacDonald on how to speed up your PHPUnit tests! Having a fast test suite can be just as important as having a fast application. As a developer, getting feedback quickly about...
View ArticleLaravel Valet Environment Variables
To set/override Environment Variables in Laravel Valet, one had to manually edit the Nginx config files and restart Nginx after doing so. With the release of Laravel Valet 2.1.6 this is no longer...
View ArticleTools to automatically format PHP, JavaScript and CSS files
Good writeup by Freek on how to get PHP-CS-Fixer and Prettier up and running. When working on a project with other people, it’s important to pick a coding standard. Agreeing on a coding standard makes...
View Articlephp-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...
View ArticleUpgrade to PHP 7.3 with Homebrew on Mac
Recently did the same but Brent was smart enough to write things down Upgrade to PHP 7.3 with Homebrew on Mac →
View Articlebramus/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...
View ArticleUnsafe 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...
View ArticleBash/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...
View Article