-
Notifications
You must be signed in to change notification settings - Fork 9
Home
Stagehand_FSM is a finite state machine (FSM).
Manual state management makes code complex, decreases intentionality. By using Stagehand_FSM, state management code can be declaratively represented in the form of FSM. This makes code simpler, increases intentionality.
Stagehand_FSM can be used as an infrastructure for domain-specific languages (DSLs). Examples are workflow engines, page flow engines such as Piece_Flow.
<?php
use Stagehand\FSM\StateMachine\StateMachineBuilder;
$stateMachineBuilder = new StateMachineBuilder();
$stateMachineBuilder->addState('locked');
$stateMachineBuilder->addState('unlocked');
$stateMachineBuilder->setStartState('locked');
$stateMachineBuilder->addTransition('locked', 'insertCoin', 'unlocked');
$stateMachineBuilder->addTransition('unlocked', 'pass', 'locked');
$stateMachine = $stateMachineBuilder->getStateMachine();
$stateMachine->start();
echo $stateMachine->getCurrentState()->getStateID() . PHP_EOL; // "locked"
$stateMachine->triggerEvent('insertCoin');
echo $stateMachine->getCurrentState()->getStateID() . PHP_EOL; // "unlocked"
$stateMachine->triggerEvent('pass');
echo $stateMachine->getCurrentState()->getStateID() . PHP_EOL; // "locked"
- Activities (Do Actions)
- Entry Actions
- Exit Actions
- Transition Actions
- Guards
- Initial Pseudo State
- Final State
- User-Defined Payload
- PHP 5.3.2 or greater
| Package | Version | Stability | Release Date | License | |
|---|---|---|---|---|---|
| Stagehand_FSM | 2.0.0 | stable | 2013-08-01 | The BSD 2-Clause License | Release Notes |
Stagehand_FSM can be installed using Composer or PEAR. The following sections explain how to install Stagehand_FSM.
First, add the dependency to piece/stagehand-fsm into your composer.json file as the following:
{
"require": {
"piece/stagehand-fsm": ">=2.0.0"
}
}Second, update your dependencies as the following:
composer update piece/stagehand-fsmpear config-set auto_discover 1
pear install pear.piece-framework.com/Stagehand_FSMgit clone https://github.com/piece/stagehand-fsm.gitIf you find a bug or have a question, or want to request a feature, create an issue or pull request for it on Issues.
Copyright (c) 2006-2008, 2011-2013 KUBO Atsuhiro <kubo@iteman.jp>, All rights reserved.