Install gnupg php extension in centos

All commands ran via SSH as root from /root. If you get “No package available” errors, you probably need to install the EPEL repositories.

yum install libgpg-error yum install libgpg-error-devel yum install gpgme yum install gpgme-devel yum install pygpgme pecl install gnupg

You will then need to edit your /usr/local/lib/php.ini file and verify/insert the extension=gnupg.so line. If this line isn’t already in the file, just add it at the bottom. Run php -m and look for a gnupg line. Next run php -r "phpinfo();". You should see something like:

gnupg support => enabled GPGme Version => 1.1.8 Extension Version => 1.3.2-dev

Then you’ll just need to restart the web server .

PHP Rest Class

A multi purpose php rest class.

<?php
/*
 * Rest Class for php
 */
class Rest {
/*
 * Request URI
 */
 private $request = NULL;
/*
 * Method called
 */
 private $method = NULL;
/*
 * Params received
 */
 private $params = array();
 /*
 * Constructor
 */
 public function __construct() {
 $this->_parseParams();
 }
/**
 * @brief Lookup request params
 * @param string $name Name of the argument to lookup
 * @param mixed $default Default value to return if argument is missing
 * @returns The value from the GET/POST/PUT/DELETE value, or $default if not set
 */
 public function get($name, $default = null) {
 if (isset($this->params[$name])) {
 return $this->params[$name];
 } else {
 return $default;
 }
 }
private function _parseParams() {
 $this->method = $_SERVER['REQUEST_METHOD'];
 if ($this->method == "PUT" || $method == "DELETE") {
 parse_str(file_get_contents('php://input'), $this->params);
 $GLOBALS["_{$method}"] = $this->params;
 // Add these request vars into _REQUEST, mimicing default behavior, PUT/DELETE will override existing COOKIE/GET vars
 $_REQUEST = $this->params + $_REQUEST;
 } else if ($this->method == "GET") {
 $this->params = $_GET;
 } else if ($this->method == "POST") {
 // Check for emulated POST
 if ($_SERVER['HTTP_X_HTTP_METHOD_OVERRIDE']) {
 $this->method = strtoupper($_SERVER['HTTP_X_HTTP_METHOD_OVERRIDE']);
 } else if ($_POST['_method']) {
 $this->method = strtoupper($_POST['_method']);
 } 
 $this->params = $_POST;
 }
 $this->request = preg_split("/\//", substr(@$_SERVER['PATH_INFO'], 1));
 }
 
 public function getMethod(){
 return $this->method;
 }
 
 public function getRequest(){
 return $this->request;
 }
 
 public function getAllParams(){
 return $this->params;
 }
 
 public function response($data, $error = NULL){
 // Data header for all responses
 header('Content-Type: application/json');
 // Standard json format status, error, data along with respective headers
 if(isset($data) && !isset($error)){
 // Send Success Header
 header('HTTP/1.1 200 OK');
 $json['status'] = "200";
 $json['data'] = $data;
 }
 else {
 // Send Failure Header
 header('HTTP/1.1 200 OK');
 $json['status'] = "500";
 $json['error'] = $error;
 }
return json_encode($json);
} // response
}
/*
// Debug
$r = new REST();
echo $r->getMethod() . "\n";
print_r($r->getRequest());
print_r($r->getAllParams());
*/