the solution to working with ipv6 in php is to exclusively work with it in sql queries, in mariadb using INET6_NTOA and INET6_ATON don't underestimate sql functions, they're wild
i dont like making sql do hard work though, maybe im autism but i always thought it'd be best to take pressure off of the thing that's hard to upscale (a db) and put it on things that are easier to upscale (e.g. multiple webservers)