{"id":19234526,"url":"https://github.com/phpmentors-jp/stagehand-fsm","last_synced_at":"2025-04-16T14:27:18.300Z","repository":{"id":500327,"uuid":"127344","full_name":"phpmentors-jp/stagehand-fsm","owner":"phpmentors-jp","description":"A finite state machine","archived":false,"fork":false,"pushed_at":"2022-07-19T01:33:07.000Z","size":538,"stargazers_count":36,"open_issues_count":4,"forks_count":9,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-03-29T05:22:41.839Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://github.com/phpmentors-jp/stagehand-fsm/wiki","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-2-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/phpmentors-jp.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2009-02-12T12:07:20.000Z","updated_at":"2023-01-06T09:54:12.000Z","dependencies_parsed_at":"2022-07-04T20:30:47.891Z","dependency_job_id":null,"html_url":"https://github.com/phpmentors-jp/stagehand-fsm","commit_stats":null,"previous_names":[],"tags_count":17,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/phpmentors-jp%2Fstagehand-fsm","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/phpmentors-jp%2Fstagehand-fsm/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/phpmentors-jp%2Fstagehand-fsm/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/phpmentors-jp%2Fstagehand-fsm/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/phpmentors-jp","download_url":"https://codeload.github.com/phpmentors-jp/stagehand-fsm/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248766731,"owners_count":21158301,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-09T16:14:12.015Z","updated_at":"2025-04-16T14:27:18.279Z","avatar_url":"https://github.com/phpmentors-jp.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Stagehand_FSM\n\nA finite state machine\n\n[![Total Downloads](https://poser.pugx.org/piece/stagehand-fsm/downloads.png)](https://packagist.org/packages/piece/stagehand-fsm)\n[![Latest Stable Version](https://poser.pugx.org/piece/stagehand-fsm/v/stable.png)](https://packagist.org/packages/piece/stagehand-fsm)\n[![Latest Unstable Version](https://poser.pugx.org/phpmentors/stagehand-fsm/v/unstable.png)](https://packagist.org/packages/phpmentors/stagehand-fsm)\n[![Build Status](https://travis-ci.org/phpmentors-jp/stagehand-fsm.svg?branch=master)](https://travis-ci.org/phpmentors-jp/stagehand-fsm)\n\n`Stagehand_FSM` is a [finite state machine](https://en.wikipedia.org/wiki/Finite-state_machine).\n\nManual 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.\n\n`Stagehand_FSM` can be used as an infrastructure for [domain-specific languages](http://en.wikipedia.org/wiki/Domain-specific_language) (DSLs). Examples are workflow engines such as [Workflower](https://github.com/phpmentors-jp/workflower), pageflow engines such as [PHPMentorsPageflowerBundle](https://github.com/phpmentors-jp/pageflower-bundle).\n\n```php\n\u003c?php\nuse Stagehand\\FSM\\StateMachine\\StateMachineBuilder;\n\n$stateMachineBuilder = new StateMachineBuilder();\n$stateMachineBuilder-\u003eaddState('locked');\n$stateMachineBuilder-\u003eaddState('unlocked');\n$stateMachineBuilder-\u003esetStartState('locked');\n$stateMachineBuilder-\u003eaddTransition('locked', 'insertCoin', 'unlocked');\n$stateMachineBuilder-\u003eaddTransition('unlocked', 'pass', 'locked');\n$stateMachine = $stateMachineBuilder-\u003egetStateMachine();\n\n$stateMachine-\u003estart();\necho $stateMachine-\u003egetCurrentState()-\u003egetStateID() . PHP_EOL; // \"locked\"\n$stateMachine-\u003etriggerEvent('insertCoin');\necho $stateMachine-\u003egetCurrentState()-\u003egetStateID() . PHP_EOL; // \"unlocked\"\n$stateMachine-\u003etriggerEvent('pass');\necho $stateMachine-\u003egetCurrentState()-\u003egetStateID() . PHP_EOL; // \"locked\"\n```\n\n## Features\n\n* Activities (do actions)\n* Entry actions\n* Exit actions\n* Transition actions\n* Transition logging\n* Guards\n* Initial pseudo state\n* Final state\n* User-defined payload\n* User-defined event dispatcher for the state machine events\n\n## Installation\n\n`Stagehand_FSM` can be installed using [Composer](http://getcomposer.org/).\n\nAdd the dependency to `piece/stagehand-fsm` into your `composer.json` file as the following:\n\nStable version:\n\n```\ncomposer require piece/stagehand-fsm \"2.6.*\"\n```\n\nDevelopment version:\n\n```\ncomposer require phpmentors/stagehand-fsm \"~3.0@dev\"\n```\n\n## Support\n\nIf you find a bug or have a question, or want to request a feature, create an issue or pull request for it on [Issues](https://github.com/phpmentors-jp/stagehand-fsm/issues).\n\n## Copyright\n\nCopyright (c) 2006-2008, 2011-2018 KUBO Atsuhiro, All rights reserved.\n\n## License\n\n[The BSD 2-Clause License](http://opensource.org/licenses/BSD-2-Clause)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fphpmentors-jp%2Fstagehand-fsm","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fphpmentors-jp%2Fstagehand-fsm","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fphpmentors-jp%2Fstagehand-fsm/lists"}