Generating public key using modulus and exponent in PHP

I have this pre-request postman script:

const modulus = session.rsa.M;
const exponent = session.rsa.E;           
const rsaKey = pmlib.rs.KEYUTIL.getKey({ n: modulus, e: exponent });
const encodedPassword = pmlib.rs.KJUR.crypto.Cipher.encrypt(session.id + '**' + password, rsaKey, 'RSA');

And now I want to do this using PHP. First I send a request to get session that contains id, modulus and exponent, then I need to encrypt password and session to send to perform login action and get cookies. Any help for that?