leafs / shu
State machine in a bottle
Fund package maintenance!
Open Collective
leafsphp
Requires
- php: ^7.4|^8.0
- ext-json: *
- ext-zip: *
- leafs/anchor: *
- leafs/db: ^2.1
- leafs/exception: *
- leafs/http: *
- leafs/router: *
Requires (Dev)
- friendsofphp/php-cs-fixer: ^3.0
- pestphp/pest: ^1.21
This package is not auto-updated.
Last update: 2024-12-21 15:49:50 UTC
README
Shū
Shū is an event-driven state (aka state machine) library for PHP. It is designed to be lightweight, easy to use and easy to extend. Unlike other state libraries, Shū is not bound to any framework and can be used in any PHP project.
🗂 Basic Usage
There are many ways to use Shū. The easiest way is to define your states and events in a state file and then load it into Shū.
<?php require __DIR__ . '/vendor/autoload.php'; $machine = createMachine([ 'initial' => 'pending', 'states' => [ 'pending', 'approved', 'rejected', ], 'transitions' => [ 'approve' => [ 'from' => 'pending', 'to' => 'approved', ], 'reject' => [ 'from' => 'pending', 'to' => 'rejected', 'action' => function () { // perform an action and return true if successful return true; }, ], ], ]);
💬 Stay In Touch
📓 Learning Leaf 3
- Leaf has a very easy to understand documentation which contains information on all operations in Leaf.
- You can also check out our youtube channel which has video tutorials on different topics
- You can also learn from codelabs and contribute as well.
😇 Contributing
We are glad to have you. All contributions are welcome! To get started, familiarize yourself with our contribution guide and you'll be ready to make your first pull request 🚀.
To report a security vulnerability, you can reach out to @mychidarko or @leafphp on twitter. We will coordinate the fix and eventually commit the solution in this project.
🤩 Sponsoring Leaf
Your cash contributions go a long way to help us make Leaf even better for you. You can sponsor Leaf and any of our packages on open collective or check the contribution page for a list of ways to contribute.
And to all our existing cash/code contributors, we love you all ❤️