I tried a couple approaches from some of the other answers here and they didn't work for me:
The official libraries and helper code from the USPS aren't very clear. They're also platform dependent and seem to be most useful if you're planning to do a mail merge in Excel or some other desktop app. If you're trying to integrate with a PHP web app, I'm not sure this is a very good route.
It seems like tc-lib-barcode doesn't use the official USPS font. It doesn't look correct when compared side-by-side and when I tried validating a barcode using this tool, it failed.
I ended up using this IMB Converter class instead. You can download the USPS official font USPSIMBStandard and then display your bar code hash using the font (it should be in the fonts/scalable/trueType folder). To generate a bar code hash, you first need to generate a code. This is outlined on page 2 of this PDF from the USPS. Once you have a code (e.g. 0027012345678955555590210), you can run it through the converter class:
$barcode = IMB::Convert('0027012345678955555590210');
This returns TFDAAFAADDTDDFDFDATADDDATDAFAFDATADADADFATAFAFAFDADATFTFDAFDTADDT. You can then inject this directly into a PDF using the USPSIMBStandard font, or display it in HTML.
<p style="font-family:'USPSIMBStandard'; color:#000; font-size: 100px;"><?php echo $barcode; ?></p>

When generating bar code hashes, it's unclear how accurate IMB::Convert is in comparison to the official USPS encoder. I tested a few combinations and they all seem to match. If you do want to use the official USPS encoder, you can run it on the command line like this:
$ IMBshell 0027012345678955555590210