PHP code example of patchstack / engine-php

1. Go to this page and download the library: Download patchstack/engine-php library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

patchstack / engine-php example snippets


use Patchstack\Processor;
use Patchstack\Extensions\WordPress\Extension;

// Load the firewall rules, whitelist rules and settings from some place.
$firewallRules = [];
$whitelistRules = [];
$settings = [];

// Setup the firewall rules processor.
$firewall = new Processor(
    new Extension(),
    $firewallRules,
    $whitelistRules,
    $settings
);

// And launch it. If a request was a hit with a firewall rule, it will automatically stop execution.
$firewall->launch();
json
[
    {
        "parameter":"post.usernames",
        "match":{
            "type":"array_in_array",
            "value":[
                "test",
                "admin"
            ]
        }
    }
]
json
[
    {
        "parameter":"get.user",
        "match":{
            "type":"not_in_array",
            "value":[
                "admin"
            ]
        }
    }
]