There is a PHP extension port of the gnupg PGP library. However, I'm having a hard time finding examples that explain how to use the library.
How do you properly create keys for application users, and then use them to encrypt/decrypt text using the GnuPG library?
See this URL it is very help full to you. Download example and try it.
https://github.com/singpolyma/openpgp-php
Or Try it:-
You can download lib/openpgp.php and lib/openpgp_crypt_rsa.php files in above the URL.
examples/keygen.php
examples/sign.php
examples/verify.php
They are very good examples based on PHP extension port has you have requested and we would take a look at some examples
Using GnuPG with PHP -- Full Tutorials
Example
Getting Key Information
Encrypt a Simple Mail
Decryption The Mail
You should also look at the Example