Fat-Free

Unlike other frameworks, Fat-Free is an extremely lightweight PHP framework.

Firewall in FatFree Framework

Installation

Use PHP Composer:

composer require shieldon/shieldon

This will also install dependencies required for Shieldon:

Implementing

Assuming your code is supposed to look like this:

<?php

require dirname(__DIR__) . '/vendor/autoload.php';

$f3 = \Base::instance();
$f3->route('GET /',
    function() {
        echo 'Hello, world!';
    }
);
$f3->run();

Steps

1. Initialize Shieldon Firewall

After this line:

require dirname(__DIR__) . '/vendor/autoload.php';

Add the following code:

Example:

// Prevent error when running in CLI environment.
if (isset($_SERVER['REQUEST_URI'])) {

    // This directory must be writable.
    $storage = dirname($_SERVER['SCRIPT_FILENAME']) . '/../shieldon_firewall';

    $firewall = new \Shieldon\Firewall\Firewall();
    $firewall->configure($storage);
    $firewall->controlPanel('/firewall/panel');
    $response = $firewall->run();

    if ($response->getStatusCode() !== 200) {
        $httpResolver = new \Shieldon\Firewall\HttpResolver();
        $httpResolver($response);
    }
}

Note:

Please create a writable directory named shieldon_firewall in the directory above. Shieldon Firewall will store data in this directory.

2. Define a Route for the Firewall Panel

Example:

$f3->route('GET|POST /firewall/panel*', function() {
    $panel = new \Shieldon\Firewall\Panel();
    $panel->entry();
});

That's it!

Now, you can access the Firewall Panel using the following URL:

https://yoursite.com/firewall/panel

The default login is shieldon_user, and the password is shieldon_pass. After logging into the Firewall Panel, the first thing you should do is change the login and password.

If Shieldon Firewall is enabled in the Daemon setting section, it will start monitoring your website. Make sure you have correctly set up the settings.