Skip to content

Test Drive¶

Follow these steps to quickly test Lite Firewall locally in a clean environment:

🧪 Quick Test Drive Setup¶

  1. Create a temporary folder

    mkdir testdrive
    cd testdrive
    touch firewall.data
    

  2. Install Lite Firewall via Composer

    composer require kanopi/firewall
    

  3. Create a basic firewall.yml configuration

 storage:
     type: "Kanopi\\Firewall\\Storage\\FileStorage"
     config:
         storage_file: firewall.data

 plugins:
     - plugin: "Kanopi\\Firewall\\Plugins\\Url"
       response: block
       enable: true
       config:
           - "query.block:1"   # Block any request that includes ?block=1
  1. Create an index.php file
<?php
require __DIR__ . '/vendor/autoload.php';

use Kanopi\Firewall\Firewall;

// Initialize firewall
Firewall::create([__DIR__ . '/firewall.yml'])->evaluate();

echo "Hello, world!";
  1. Start a PHP built-in web server

    php -S localhost:8000
    

  2. Open your browser and test

  3. Visit http://localhost:8000 — you should see:

    Hello, world!
    

  4. Visit http://localhost:8000?block=1 — you should see:

    Request Blocked
    

  5. Visit http://localhost:8000 — you should see:

    Request Blocked
    

This simple example demonstrates how the firewall intercepts requests using YAML configuration and shows how easy it is to add rule-based blocking.

To start over empty the contents of the Storage file

echo "" > firewall.data