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:
https://gist.github.com/ivoba/d8c4379236149a8c42e1922ae98a93e3
Basically you have to install composer patch:
composer require cweagans/composer-patches
Create the patch and add the patch file to your project.
You can create a patch by cloning the package i.e. silverstripe/framework into IntelliJ / PHPStorm, apply the change and under Git -> Patch create the patch file.
Then add it to composer.json so the patch can be applied on next composer install
.
"extra": {
"patches": {
"silverstripe/framework": {
"Fix SilverStripe deprecations error_reporting for PHP 8.1": "./fix-deprecation-error_reporting.4.10.4.patch"
}
}
}
Now we have patched the error_reporting and the deprecation warnings are supressed.
Once SilverStripe fully supports PHP8.1 we then can remove this patch.