Strict Standards: Redefining already defined constructor for class RuleElement in /home/iepmodel/files.iepmodel.net/php-rules-sample/system/application/libraries/Phprules/Ruleelement.php on line 31

Strict Standards: Redefining already defined constructor for class Operator in /home/iepmodel/files.iepmodel.net/php-rules-sample/system/application/libraries/Phprules/Ruleelement.php on line 89

Strict Standards: Redefining already defined constructor for class Proposition in /home/iepmodel/files.iepmodel.net/php-rules-sample/system/application/libraries/Phprules/Ruleelement.php on line 130

Strict Standards: Redefining already defined constructor for class Variable in /home/iepmodel/files.iepmodel.net/php-rules-sample/system/application/libraries/Phprules/Ruleelement.php on line 216

Strict Standards: Redefining already defined constructor for class DateVariable in /home/iepmodel/files.iepmodel.net/php-rules-sample/system/application/libraries/Phprules/Datevariable.php on line 30

Strict Standards: Redefining already defined constructor for class RuleContext in /home/iepmodel/files.iepmodel.net/php-rules-sample/system/application/libraries/Phprules/Rulecontext.php on line 27

Strict Standards: Redefining already defined constructor for class Rule in /home/iepmodel/files.iepmodel.net/php-rules-sample/system/application/libraries/Phprules/Rule.php on line 72
Welcome to the PHP Rules sample application (on the CodeIgniter framework)

Welcome to the PHP Rules sample application
(on the CodeIgniter framework)

Thanks for your interest in PHP Rules. This sample application provides two examples of using PHP Rules. Before you can execute the samples or unit tests, you should also install the sample database (if you haven't already).

Table of contents

API

Phprules API (phpdocs)

Unit tests

Phprules library unit tests (You must first install before you can execute unit tests)

Overview

What is PHP Rules?

PHP Rules is a lightweight, forward-chaining inference engine based on the "Rule Archetype Pattern" described in chapter 12, "Rule archetype pattern," in the excellent book Enterprise Patterns and MDA: Building Better Software with Archetype Patterns and UML.

PHP Rules models formal propositional logic. It allows you to separate conditional logic from source code and database triggers in a reusable package, where explicit rules can be independently defined & managed.

Rules are simple statements of fact about the state of something that may be used explicitly to trigger actions.

Phprules Package Class Diagram

Install the sample database

This section describes how to install a sample project with PHP Rules, and how to get it running.

Note: You will find detailed, step-by-step instuctions on-line at the "Install the PHP Rules sample application" page on the PHP Rules website, including steps for installing a database using cPanel.

Prerequisites

Before you begin, you must have the following installed:

  1. Apache HTTP server - This tutorial assumes you're using Apache as a web server. PHP Rules should also run fine on ISS, but it's currently untested.
  2. PHP - As the name implies, PHP Rules runs on PHP. If you're reading this, you have PHP installed.
  3. MySQL Community Server - In its current version, PHP Rules can run without a relational database. In the near future, however, this will be required. As you'll see in the examples section, business information is normally stored in multiple databases. PHP Rules provides a way of capturing business information in a common way.

Step 1: Install the demo database via the mysql command line

  1. Log in to the MySQL server:
    shell> mysql --user=user_name --password=your_password
    
    where
  2. Create the airlines schema:
    mysql> create database airlines;
    
  3. Create a new user called usr_airlines:
    mysql> create user 'usr_airlines'@'localhost' identified by 'password';
    
  4. Assign privileges to usr_airlines:
    mysql> grant all privileges on `airlines`.* to 'usr_airlines'@'localhost';
    

Step 2: Configure the system/application/config/database.php file to connect to your database

The sample application runs on CodeIgniter, so you have to configure it to connect to your new database.

  1. Open php-rules-sample/system/application/config/database.php in a text editor.
  2. Fill out the following with the values you saved in Step 1:
    $db['default']['username'] = "usr_airlines";
     
    $db['default']['password'] = "password";
     
    $db['default']['database'] = "airlines";
    	
  3. Save the file php-rules-sample/system/application/config/database.php.

Step 3: Run the "PHP Rules Demo Installation Wizard"

Your database appears to be properly configured. You can proceed with installation (if you haven't already installed it).
It appears that this sample application cannot connect to a database. Be sure to configure your database connection by opening the following file in a text editor php-rules-sample/system/application/config/database.php and filling out the following values:
$db['default']['hostname'] = "localhost";
 
// Provide the user name from Step 2 of "Install the PHP Rules sample application"
// http://swindle.net/php-rules/tutorials/getting-started/install-php-rules-sample-application#step-2
$db['default']['username'] = "";
 
// Provide the password from Step 2 of "Install the PHP Rules sample application"
// http://swindle.net/php-rules/tutorials/getting-started/install-php-rules-sample-application#step-2
$db['default']['password'] = "";
 
// Provide the database name from Step 2 of "Install the PHP Rules sample application"
// http://swindle.net/php-rules/tutorials/getting-started/install-php-rules-sample-application#step-2
$db['default']['database'] = "";
 
$db['default']['dbdriver'] = "mysql";
$db['default']['dbprefix'] = "";
$db['default']['pconnect'] = TRUE;
$db['default']['db_debug'] = TRUE;
$db['default']['cache_on'] = FALSE;
$db['default']['cachedir'] = "";
$db['default']['char_set'] = "utf8";
$db['default']['dbcollat'] = "utf8_general_ci";

Once you're done, reload this page.

For detailed installation instructions, be sure to create the demo database and user and configure the sample application.



Page rendered in 0.3869 seconds