Remove unnecessary polyfills from composer

Remove unnecessary polyfills from composer
Photo by Hello I'm Nik / Unsplash

Frameworks like Symfony and packages include a lot of polyfills. Not just for extensions but also for older PHP versions. It's not really a bad thing, I use it myself in one of my packages.
As far as I'm aware, having them installed has no measurable performance impact. But it's still more stuff that's installed and needs to be pulled on every CI run. If they don't offer any benefit, they don't need to be there.

You can skip them through using the keyword replace in your composer.json like the following:

"replace": {
  "symfony/polyfill-php56": "*",
},

Depending on the project, there might be quite a few. In one of my projects it looks like this:

  ...
},
"replace": {
  "symfony/polyfill-intl-grapheme": "*",
  "symfony/polyfill-intl-idn": "*",
  "symfony/polyfill-intl-normalizer": "*",
  "symfony/polyfill-mbstring": "*",
  "symfony/polyfill-php56": "*",
  "symfony/polyfill-php70": "*",
  "symfony/polyfill-php71": "*",
  "symfony/polyfill-php72": "*",
  "symfony/polyfill-php73": "*",
  "symfony/polyfill-php80": "*",
  "symfony/polyfill-php81": "*",
  "symfony/polyfill-ctype": "*",
  "symfony/polyfill-iconv": "*",
  "symfony/polyfill-uuid": "*"
},

I think that's worth saving.