Download the PHP package troojaan/laravel-state-machine without Composer

On this page you can find all versions of the php package troojaan/laravel-state-machine. 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 laravel-state-machine

Winzou State Machine service provider for Laravel

Latest Version on Packagist Build Status Scrutinizer Code Quality StyleCI

This is a Laravel service provider for winzou/state-machine.

Features

Installation

You can install the package via composer. This package requires Laravel 5.1 or higher.

Since version 5.5, Laravel uses package auto-discovery, so you don't need to manually add the ServiceProvider and the facade. If you don't use auto-discovery or you are using an older version, add the service provider and the facade in config/app.php.

Configuration

Publish the config file in config/state-machine.php.

Please see the documentation of the StateMachineBundle for all the available options.

Usage

Now you can use the $stateMachine to interact with the state of the $article.

Callbacks

Callbacks are used to guard transitions or execute some code before or after applying transitions.

This package adds the ability to resolve callbacks and inject their dependencies from Laravel's Service Container.

Defining a callback

Under the callbacks.guard array of your configuration, add an associative array to define the callback. The key of the array can be anything you want (e.g. guard_on_submitting). This array must have a clause, a callback, and may have some arguments.

Clause

First, you need to specify a clause that will determine when the callback will be invoked. A clause has a key (from, to, on, excluded_from, excluded_to, excluded_on) and its value is the state or the transition that should satisfy the clause.

E.g. 'on' => 'submit_changes' will be triggered when the transition submit changes is being checked or applied.

Callback

Second, you need to specify the callback that will be invoked under the do key. The callback must be a callable, and can be one of the following:

A closure:
A built-in or user-defined function as a string:
A class method as array:

Classes are resolved through the service container with their dependencies.

A class method as string:
Arguments
Using dependency injection

By default, if you don't specify the args key in your array, all the callback method parameters will be injected automatically using Laravel's service container, like Route/Controller methods.

Type-hints

All type-hinted parameters are resolved from the container, e.g. App $app.

Object in the state machine

If a parameter has the same type-hint as the object that is associated to the state machine, e.g. App\Article $article, the instance will be injected.

State machine event

If a parameter has the state machine event type-hint, e.g. SM\Event\TransitionEvent $e, the event that was triggered in the state machine will be injected. Alternatively you can define a parameter named $event without a type-hint.

Using ExpressionLanguage notation

Otherwise, you can define one or multiple arguments that will be passed explicitly to your callbacks in the given order, by using the args key. This package is using Symfony's ExpressionLanguage notation to evaluate expressions.

Here are some examples:

Example

You want to call the handle method on the MyService class to determine if the state machine can apply the submit_changes transition. The handle method will receive the object of the state machine as the first argument, and the transition event as the second argument.

Events

When checking if a transition can be applied, the SM\Event\SMEvents::TEST_TRANSITION event is fired.

Before and after a transition is being applied, the SM\Event\SMEvents::PRE_TRANSITION and SM\Event\SMEvents::POST_TRANSITION events are fired respectively.

All the events receive an SM\Event\TransitionEvent instance.

If you wish to listen to all the events with the same listener, you can use the winzou.state_machine.* wildcard parameter.

You can define your own listeners in your app's EventServiceProvider. E.g.:

Debug command

An artisan command for debugging graphs is included. It accepts the name of the graph as an argument. If no arguments are passed, the graph name will be asked interactively.

Changelog

Please see CHANGELOG for more information what has changed recently.

Testing

Contributing

Please see CONTRIBUTING for details.

Security

If you discover any security related issues, please email Sébastien at [email protected] instead of using the issue tracker.

Credits

License

The MIT License (MIT). Please see License File for more information.


All versions of laravel-state-machine with dependencies

PHP Build Version
Package Version
Requires php Version ^5.5.9 || ^7.0
illuminate/support Version 5.1.* || 5.2.* || 5.3.* || 5.4.* || 5.5.* || 5.6.*
winzou/state-machine Version ^0.3.2
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 troojaan/laravel-state-machine contains the following files

Loading the files please wait ....