How to convert this piece of java code to equivalent php code?

This is an api signing key maker.I want to convert this into php code as this is not able to integrate into my php project.

public static String signingkey(String apiAccessKey, String hmacSecretKey, String apiMethod, String clientip, String jsonInput) {
String retval = "";
final String HMAC_SHA_512_ALGORITHM = "HmacSHA512";
final String userKey = apiAccessKey + hmacSecretKey;
try {
// get an hmac_sha512 key from the raw key bytes
SecretKeySpec signingKey = new SecretKeySpec(userKey.getBytes(), HMAC_SHA_512_ALGORITHM);
// get an hmac_sha512 Mac instance and initialize with the signing key
Mac mac = Mac.getInstance(HMAC_SHA_512_ALGORITHM);
mac.init(signingKey);
// compute the hmac on input data bytes
String payload = (apiMethod.toUpperCase()).concat(clientip).concat(jsonInput);
byte[] rawHmac = mac.doFinal(payload.getBytes());
// the value of hmac needs to placed in headers under the key api-hmac
return Hex.encodeHexString(rawHmac);
} catch (Exception e) {
throw new RuntimeException(e);
}
}