Hopefully commercial solutions are also ok for you, so give a try to our product PD4ML.
PD4ML is a platform-independent tool/library written in Java, and it can be good integrated into PHP environment.
In order to produce PDFs you need to create PHP/HTML the way you normally do and let PD4ML to convert it to PDF.
Take a look to HOWTO document: http://pd4ml.com/php.htm
There is a download link there with all the stuff you need to generate PDFs from PHP: environment test script, PD4ML library itself, demo PHPs.
PD4ML allows to define footers (or headers) like that:
<pd4ml:page.footer>
<font color=red>Footer text. Page $[page] of $[total]</font>
</pd4ml:page.footer>
scope attribute allows you to set a page range the footer should appear on.
scope="2+" or scope="odd" or scope="1,4-7"
If you need the footer appearance only on the last page, probably <pd4ml:footnote noref>Footer text</pd4ml:footnote> tag
at the end of the document content is even a better solution.
Of course you may achieve the same result with absolute positioned elements (also supported by PD4ML), but the page footer and footnote tags turns the task into a trivial one.