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...
View ArticleSymfony 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...
View ArticleGetting 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...
View ArticlePHP in 2019
If it’s been a while that you’ve touched PHP (like say, from before version 7.0) or have no idea what the language can do for you, Brent has a nice writeup on the state of PHP in 2019: Let’s focus on...
View ArticleExceptional 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 fourth argument named $previous. It defines the previous...
View ArticlePHP 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...
View ArticleInternal classes in PHP
As a (PHP) package developer, you sometimes have classes that are meant for internal use – inside the package itself – only. PHP has no built-in solution for this, but using a DocBlock Tag one can...
View Articlespatie/test-time – A PHP package to control the flow of time
Freek has created spatie/test-time, a package to easily freeze/rewind/advance time in PHP. Imagine you’re building that your app can notify your user, but you don’t want to send more than one...
View ArticleTyped Properties in PHP
As mentioned before I’m really looking forward to Typed Properties that will land in PHP 7.4 (now in alpha!). Brent has done a full writeup on ‘m: In this post we’ll look at the feature in-depth, but...
View ArticleConnect to Remote MySQL Server with SSL Certificates from PHP: Fixing the...
Photo by Clem Onojeghuo on Unsplash To connect to a MySQL Server that requires SSL from PHP with PDO, you can use this piece of code: try { $db = new PDO('mysql:host=DB_HOST;dbname=DB_NAME', $user,...
View ArticleEasily find and remove old and heavy node_modules/vendor folders with npkill
When working in web, you can be left with several lost node_modules (JS) and vendor (PHP) folders spread across your filesystem, unnecessarily taking up space. To find these, I use the following...
View ArticleRun prettier or php-cs-fixer with GitHub Actions
Stefan Zweifel shares his GitHub Actions Workflows to run prettier and php-cs-fixer on his repos: Over the past few weeks I’ve added a handful of workflows to my projects. One workflow is really like,...
View ArticleOverriding the PHP version to use when installing Composer dependencies
If you have a (legacy) PHP project running on a legacy server (running PHP 5.4.27 for example), but are locally developing with a more modern PHP version (PHP 7.4 for example), you might end up...
View ArticleWorking with symlinked packages in PHP
When developing a PHP library/package, you most likely also have a project on disk that consumes said library. Take a WordPress plugin for example: to test it, you need a WordPress installation — both...
View ArticleGitHub CI Workflow for PHP applications
Mattias Geniar has shared his GitHub Workflow to make GitHub do the CI work for PHP applications: on: push name: Run phpunit testsuite jobs: phpunit: runs-on: ubuntu-latest container: image:...
View ArticleUse C, Rust, Go, etc. code inside PHP with “Foreign Function Interface“ (PHP...
A new extension that comes with PHP 7.4 (which was released today 🎉) is Foreign Function Interface. On the JoliCode Paris website there’s a nice article introducing it: PHP Foreign Function Interface,...
View ArticleAutomatically upgrade your PHP code from 5.3 to PHP 7.4 with Rector
Rector is a reconstructor tool – it does instant upgrades and instant refactoring of your code. Why refactor manually if Rector can handle 80% for you? Installation per Composer: composer require...
View ArticleUpgrade to PHP 7.4 with Homebrew on Mac
Brent has done a writeup on how to upgrade your Homebrew-installed PHP version to PHP 7.4. Since the php formula now contains that 7.4 version (instead of 7.3 before), all you need to do is make sure...
View ArticleHow to set up PHP for use in a GitHub Action
To use PHP in a GitHub action there’s the magnificent setup-php action. It also allows for installing extensions and setting several php.ini directives. steps: - name: Checkout uses:...
View ArticleRun a PHP app in a Docker Container (Notes)
The past week I took a closer look at the several options on how to run a PHP app with Docker. In the past I’ve ran a few pre-built containers, but now I wanted to truly get to the bottom of it all as...
View Article