Download the PHP package michaelmoussa/noodle without Composer

On this page you can find all versions of the php package michaelmoussa/noodle. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package noodle

noodle

Noodle is a finite statemachine written in PHP 7

Build Status Code Coverage Scrutinizer Code Quality Latest Stable Version Latest Unstable Version

Installation

The only officially supported method of installation is Composer

Usage

A simple example

Let's begin with the simple example of a traffic light.

There are three colors - red, yellow, and green. Red lights turn green, green lights turn yellow, and yellow lights turn red.

Such a system would look something like this:

Current State Input Next State
RED CHANGE_COLOR GREEN
GREEN CHANGE_COLOR YELLOW
YELLOW CHANGE_COLOR RED

We can build a statemachine to represent that with Noodle as follows:

Events

The above is fairly straightforward, but not terribly interesting. What if we need to do something special before or after a light changes color? We can implement that logic using events.

There are a total of twelve events that a Noodle statemachine will emit which you can listen for. They are, in order:

Suppose that, before every time the light changed color, you wanted to announce it out loud. Here's one way you could hook that up:

Now, before any light changes color, it will announce the color that it's going to turn to. You can hook into other events using ->after(...), with an optional 4th int parameter representing this event listener's priority relative to other listeners.

Noodle uses the popular league/event library for its event system, and provides the InvokableListener abstract class for convenience, but you're free to use your own listeners so long as the implement the League\Event\ListenerInterface.

Failures and State Changes

If any of the listeners triggered prior to the state transition indicates it has failed by calling the $event->stopPropagation() method, Noodle will execute the Noodle\Listeners\ReportsTransitionFailures listener, which throws a StateTransitionFailed exception. This is the default error handling mechanism used by Noodle. If you want to handle errors differently, you can pass your own listener as the optional 2nd parameter to the Statemachine constructor, and it will be used instead. Naturally, if you throw an exception in one of your listeners rather than stopping propagation, then Noodle will allow that exception to propagate out to your application.

State transitions are, by default, handled by the Noodle\Listener\ChangesState listener, which simply calls the setCurrentState(...) method of your Stateful object. This listener is triggered by the only on event that Noodle emits. You shouldn't need to make any changes to it that can't be otherwise done in an event listener, but if you absolutely must, you can pass your own listener as the 3rd parameter to the Statemachine constructor, and Noodle will use that listener instead of the default ChangesState listener to update the object's state. Of course, you can also add to the existing state transition logic by adding your own listener to on at a higher or lower priority, but you may find it easier to simply use before or after.

Context

Noodle automatically creates a "context" object before it starts triggering events, which is passes throughout the event cycle. This can be used to carry information from one listener into another. For example, suppose you had three before listeners that performed a variety of operations, and then a final before listener that logged all of the results before executing the state transition. You could add the operation results to the $context object in your listeners, and then read the $context in the logging listener to write the data to your log.

Note that a new context is created at the start of any state transition, and it will cease to exist at the end of the event cycle, so you must use it in an event listener prior to event cycle being completed. The context object is a simple ArrayObject, which should be flexible enough for most use cases.


All versions of noodle with dependencies

PHP Build Version
Package Version
Requires php Version ^7.0
league/event Version ^2.1
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package michaelmoussa/noodle contains the following files

Loading the files please wait ....