Simple access control using Htaccess.
This library is currently under development. Things will change!
Via Composer
$ composer require jpkleemans/htaccess-firewall:dev-masterFirst, create an instance of the HtaccessFirewall\HtaccessFirewall class:
$firewall = new HtaccessFirewall('path/to/.htaccess');$host = IP::fromString('123.0.0.1');
$firewall->deny($host);$host = IP::fromString('123.0.0.1');
$firewall->undeny($host);$hosts = $firewall->getDenied();$firewall->deactivate();
// And to reactivate:
$firewall->reactivate();$hosts = $firewall->set403Message('You are blocked!');
// And to remove:
$hosts = $firewall->remove403Message();You can use another filesystem by passing it as the second argument of the HtaccessFirewall constructor.
The filesystem must implement the HtaccessFirewall\Filesystem\Filesystem interface.
$filesystem = new YourCustomFilesystem();
$firewall = new HtaccessFirewall('path/to/.htaccess', $filesystem);$ phpspec run