PHP Interactive Mode via SSH

I’m trying to access the PHP interactive mode via ssh, but after type “php -a”, the prompt answer me “Interactive mode enable”, but I cannot type anything.

Does anyone have the same problem?

Hey @lincolnlemos

You’re not alone – I just verified that this is the case in my Local site container.

According to this StackOverflow answer, PHP needs to have the readline module:

There isn’t an easy way to compile this into the container, but there are a couple of options that you can do to quickly evaluate php code from the terminal, but nothing that’s really interactive:

  1. Use wpcli: wp eval '<php-code>'
  2. Use Ctrl+d to execute things
    • One of the answers in the above StackOverflow question mentions entering into interactive mode with php -a and then adding the full php code and then Ctrl+d. This will flush the session and therefore isn’t “interactive”, but is a way to get PHP to execute code locally.

Hope that helps give a couple of options for working around this!