In the case of Etheruem Wallet, the private key is encrypted with a passphrase and stored locally in an extensionless keystore file (JSON format, but no extension) with some additional data.
The public key is generated from the private key, and then encrypted into a json (keystore) file with your passphrase and something called salt, which is a randomly generated value.
The public key can be derived from the private key but the reverse is not possible. One can not derive the private key from the public key. The passphrase is used to encrypt the private key. So with the help of the passphrase, one can derive private key and with the help of private key one can derive public key.
Passphrase -> Private Key ->Public Key
This is an inherent feature of the asymmetric cryptographic algorithm.
According to an accepted answer of this question, ethereum uses Elliptic Curve Digital Signature Algorithm to generate the key pair. You will have to implement the same in PHP.