$serial->deviceOpen();$serial->sendMessage($cmd);sleep(1);$read = $serial->readPort();$serial->deviceClose();Open the part, resetting the Arduino. Immediately send a message, which will be lost as the Arduino isn't ready to receive serial data yet. Sleep for a second, while the Arduino boots up. See if there is any serial data (there may not be any). Then, close the port, resetting the Arduino again.

Quote

Here is my arduino sketch:

No, that is a small part of the sketch. Useless, as we can't see where or when that is called.

Open the part, resetting the Arduino. Immediately send a message, which will be lost as the Arduino isn't ready to receive serial data yet. Sleep for a second, while the Arduino boots up. See if there is any serial data (there may not be any). Then, close the port, resetting the Arduino again.

Then, clearly the python method of opening the serial port is doing something that the PHP method of opening the serial port is not doing. You need to investigate all the options for the phpSerial object, to see what else needs to be set in order to open the serial port correctly.