What are some potential alternatives to using SSH in PHP for controlling relays on a RaspberryPi?

Using SSH in PHP to control relays on a Raspberry Pi can be cumbersome and may not be the most secure method. A potential alternative is to use a library like PiPHP GPIO, which allows direct control of the GPIO pins on the Raspberry Pi without the need for SSH.

// Include the PiPHP GPIO library
require_once 'vendor/autoload.php';

use PiPHP\GPIO\GPIO;
use PiPHP\GPIO\Pin\PinInterface;

// Create a new GPIO object
$gpio = new GPIO();

// Open pin 17 for output
$pin = $gpio->getOutputPin(17);

// Set the pin value to high
$pin->setValue(PinInterface::VALUE_HIGH);

// Close the GPIO connection
$gpio->cleanup();