Should I Fix or Swap the Libraries?

It depends on the state of the library and how hard it would be to swap for a new one. Upgrading a library is generally not as hard as people think, since you rarely need to fix the entire library, only the parts used by the application.

Check for Upgraded Version

If there is a more recent version of the library compatible with your target PHP version, look at how similar it is to the original. If the usage changed too significantly, then the effort of fixing all your code to work with the new library might not be worth it.

Occasionally, there are unofficial repositories of the library that the community upgraded to the latest version, even if not completely. It could be a good starting point to avoid duplicating work.

What if it's Abandoned?

Libraries are often abandoned and there are no replacements that run on the most recent PHP version. Upgrading some libraries, like frameworks and ORMs, is often an order of magnitude harder than simply upgrading them to the latest PHP yourself.

You will need to weight the effort of upgrading what you have to work with the latest PHP versus changing your entire application to work with the new library. This approach is generally more risky, as there are more opportunities to break things.

What About Support?

If you're using a library that is out of support, then you may be infringing on your company policies or the PCI compliance. In that case, merely making it work is not enough, and you will have to pick a supported library regardless.

However, if you've already been out of support for some time, then maybe upgrading the PHP version as an intermediate step would be useful. Then you can at least run the latest PHP version, while you're planning the more involved library migration. Breaking things down into smaller, achievable tasks can help.

Learn about more topics