I know this is pretty old... but if it's relevant to me now, it can be relevant to others too.
I just worked out this method of getting page numbers, as the methods listed here are inefficient and extremely slow for large PDFs.
$im = new Imagick();
$im->pingImage('name_of_pdf_file.pdf');
echo $im->getNumberImages();
Seems to be working great for me!