Do any PHP libraries exist for parsing ASN.1 or generating PHP code based on it?
Just in case somebody else is looking for an answer on this one: You may try PHPASN1 for a pure ASN.1 encoding and decoding library, or phpseclib which can also handle ASN.1, but it isn't as focused on it.
I am the developer of FGrosse/PHPASN1.
Try this one: https://web.archive.org/web/20160305171509/http://phpkode.com/source/s/mistpark-server/library/asn1.php.
It's not so much a library as a script, but you can use it like one.
phpseclib can decode ASN.1 structures identically to how OpenSSL's asn1parse does it:
http://phpseclib.sourceforge.net/x509/asn1parse.php
If you look at the source code it takes an array that $asn1->decodeBER returned and renders that into the string that's displayed. But the fact that it's identical is testament to phpseclib's power I think.