Since SilverStripe 4.10 is not yet fully ready for PHP8.1 you wil receive quite some deprecation warnings in dev mode when you are brave and run it nonetheless on PHP8.1.
Deprecated: SilverStripe\Config\Collections\MemoryConfigCollection implements the Serializable interface, which is deprecated. Implement __serialize() and __unserialize() instead (or in addition, if support for old PHP versions is necessary) in /var/www/html/vendor/silverstripe/config/src/Collections/MemoryConfigCollection.php on line 13
Unfortunatly we can’t control the error_reporting from SilverStripe since it is set in the kernel of the framework.
So we are forced to hack the Kernel which is rather unfortunate.
In the SilverStripe Slack channel someone proposed to use composer-patch which will apply a patch to a given vendor dependency during composer install.
This is quite cool because you don’t need to fork the dependency and take care of getting upstream changes.
So i went this path down and it looks like in this gist:
Continue reading “Disable SilverStripe deprecation warnings in PHP8.1”
When testing deprecations with PHPUnit greater than 9.5.10 you might encounter this error:
Failed asserting that exception of type "PHPUnit\Framework\Error\Deprecated" is thrown.
The code in the test is as follows:
and the code that should be tested is like this:
Continue reading “Testing Deprecations with PHPUnit”
So we have a CSV file with a member list and we want to filter all empty emails.
With nodejs streams this is almost a one liner.
We will use the csv package from the CSV project which has some sophisticated packages to parse and transform csv data with nodejs streams.
We will further use node as ESM (ECMAScript modules) to be shiningly modern and so lets create a file:
Note the .mjs extension, which will tell node to interprete this as ESM. (Since nodejs v12.20.0 && v14.13.0)
We import the packages and create the filesystem streams to read the file, then built a pipeline with the streams and the single steps to process the data and write the results into a new file.
Continue reading “Filter a csv file with nodejs streams”
Ok let’s go:
I was about to integrate Github Actions to one of my pet projects but the tests failed with:
convert-im6.q16: unable to read font `helvetica' @ error/annotate.c/RenderFreetype/1338.
In the project i was using ImageMagick
Continue reading “ImageMagick: unable to read font”
convert command directly as sub process and obviously some fonts where missing.
Makes sense because i used convert to add text to an image.
bin/console make:entity on Mysql and then later you switch your application to Postgres and you have a table called
user, which you most likely have when using security component of Symfony.
Then you will receive an error because
user is a reserved word in Postgres!
Continue reading “Migrating user table from Mysql to Postgres with Symfony and Doctrine”
An exception occurred while executing 'INSERT INTO user (id, email, roles, password, is_verified) VALUES (?, ?, ?, ?, ?)' with params [3, "firstname.lastname@example.org", "", "your-encrypted-password", 0]:
SQLSTATE: Syntax error: 7 ERROR: syntax error at or near "user"
LINE 1: INSERT INTO user (id, email, roles, password, is_verified) V...
So here is nice chain of docker errors and its solution.
1. Docker has reached its maximum of created networks and errors like this:
ERROR: could not find an available, non-overlapping IPv4 address pool among the defaults to assign to the network
The easiest (and most brute though) solution to this is to prune all networks, as suggested here on SO.
docker network prune
This will delete all networks that are not connected to currently active containers.
Continue reading “Recreate pruned docker networks with docker-compose”
But this also means it will delete all networks of your not runnning dev projects.
(Which might be numerous as in my case.)
Esbuild is the new cool kid in the bundler world.
It is super fast since its written in Go and comes with a lot of builtin features for modern frontend development.
So i wanted to try it myself and migrated a former gulp build to esbuild.
So Esbuild was not working out of the box but needed some extra config and the Sass plugin.
npm i -d esbuild esbuild-plugin-sass
Continue reading “Migrating from gulp to esbuild”
You might encounter this deprecation message after your upgrade to symfony 5.1 in your symfony project:
Since symfony/dotenv 5.1: Passing a boolean to the constructor of “Symfony\Component\Dotenv\Dotenv” is deprecated, use “Dotenv::usePutenv()
To fix this, go to config/bootstrap.php and remove the
false from the Dotenv constructor:
Actually the file config/bootstrap.php has been removed from symfony 5.1 and was replaced in public/index.php.
But since the project was updated from an symfony 4 version the bootrap file is still present.
So another option would be to remove the boostrap file and update the project entirely to symfony 5.1 recipe.
This is not trivial though as you can see in this corresponfing PullRequest.
Calculating European VAT Rates with PHP – the easy way.
Disclaimer: No legal advice, just a little experience report.
If you sell digital things (services, digital goods etc.) to EU countries, you might have to calculate the VAT at the rate of the customer’s country (and even pay it there afterwards).
Continue reading “EU/VAT – Mehrwertsteuer Madness”
The latter is even the more inconvenient part, but at least the first part can be done quite easily with good old PHP.
I recently switched from PHPStorm to IntelliJ Ultimate because of some Java. But still i am working a lot on PHP and symfony projects.
One thing i usually do on symfony projects in PHPStorm is to edit the “Directories” in the settings to avoid having results from var/cache or var/logs in the search results.
Also it slows down the search which i heavily use. So i exlude all folders that should not be searched because they are cache files or are redundant in some other way.
Continue reading “Directories settings in PHPStorm and IntelliJ Ultimate”