PHP code example of lesichkovm / php-state-machine
1. Go to this page and download the library: Download lesichkovm/php-state-machine library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
$lamp = new SmartLamp;
$lamp->dayOrNight = "day"; // We tell the lamp its day
// This will not execute, as its currently day time
if ($lamp->canTransition(SmartLamp::TRANSITION_TO_ON)) {
$lamp->applyTransition(SmartLamp::TRANSITION_TO_ON);
}
$lamp->dayOrNight = "night"; // Now we tell the lamp its night
// This will execute, as its currently night time
if ($lamp->canTransition(SmartLamp::TRANSITION_TO_ON)) {
$lamp->applyTransition(SmartLamp::TRANSITION_TO_ON);
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.