Download the PHP package vouchedfor/rules-bundle without Composer

On this page you can find all versions of the php package vouchedfor/rules-bundle. 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 rules-bundle

RulesBundle

This bundle creates the facility to add a basic rules engine. It's inspired by this article: http://jwage.com/post/76799775984/using-the-symfony-expression-language-for-a-reward

The bundle creates a Rule entity which is comprised of three elements:

1. Event - the dispatched event that causes this rule to be invoked (e.g. 'user:registered')
2. Conditions - a json array of expressions. (e.g. '["data.age > 67", "data.weight > 200"]') See [http://symfony.com/doc/current/components/expression_language.html](http://symfony.com/doc/current/components/expression_language.html) for more on the ExpressionLanguage component.
3. Actions - a json array of events to be dispatched. (e.g. '["user:mark-as-retired", "user:send-email|Retirement"]'.  Note that it is possible to send a single parameter by adding a '|' after the name of the action/event to be dispatched)

Installation

First, install it with composer:

composer require vouchedfor/rules-bundle:dev-master

Then, add the following in your AppKernel bundles (note that 'new DataDog\AuditBundle\DataDogAuditBundle(),' may have been added previously).

// app/AppKernel.php
public function registerBundles()
{
    $bundles = array(
        ...
        new VouchedFor\AuditUiBundle\VouchedForRulesBundle(),
        ...
    );
    ...
}

Create the 'rule' database table used by the bundle:

Using Doctrine Migrations Bundle:

php app/console doctrine:migrations:diff
php app/console doctrine:migrations:migrate

Using Doctrine Schema:

php app/console doctrine:schema:update --force

Usage

Create a class that extends VouchedFor\RulesBundle\Event\RuleEvent.

Add the events you want to listen to as tags for a RuleListener service (in this example, 'user:mark-as-retired' and 'user:send-email'):

// app/config/services.yml
app.rule.listener:
    class: VouchedFor\RulesBundle\EventListener\RuleListener
    arguments:
      - "@doctrine.orm.entity_manager"
      - "@event_dispatcher"
    tags:
      - { name: kernel.event_listener, event: user:registered, method: handleEvent }
      - { name: kernel.event_listener, event: user:updated, method: handleEvent }

Add a listener/subscriber to listen to the dispatched actions when a rule passes. For example:

<?php
namespace AppBundle\EventListener;

...

class UserSubscriber implements EventSubscriberInterface
{
    public static function getSubscribedEvents()
    {
        return [
            'user:mark-as-retired' => 'userMarkAsRetired',
            'user:send-email' => 'userSendEmail',
            ];
    }

    public function userMarkAsRequired(UserEvent $event)
    {
        $entity = $event->getEntity());
           $entity->setStatus('retired');

        ...
    }

    public function userSendEmail(UserEvent $event)
    {
        $entity = $event->getEntity());
        $parameter = $event->getActionParameter());

        $this->sendMail($entity, $parameter);  // Send email to $entity with template $parameter

        ...
    }

License

The Rules Bundle is free to use and is licensed under the MIT license


All versions of rules-bundle with dependencies

PHP Build Version
Package Version
Requires symfony/framework-bundle Version ~2.8|~3.0|~4.0
symfony/expression-language Version ~2.8|~3.0|~4.0
symfony/validator Version ~2.8|~3.0|~4.0
doctrine/orm Version 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 vouchedfor/rules-bundle contains the following files

Loading the files please wait ...