PHPackages                             oyeaussie/phpfirewall - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [CLI &amp; Console](/categories/cli)
4. /
5. oyeaussie/phpfirewall

ActiveLibrary[CLI &amp; Console](/categories/cli)

oyeaussie/phpfirewall
=====================

PHPFirewall is a tool to allow/block connections to your web resource using IP address. The IP address details are either retrieved from local database or by making API calls to IP2Location.io

1.2.1(1y ago)555[6 issues](https://github.com/oyeaussie/PHPFirewall/issues)1MITPHPPHP ^7.2.5 || ^8.0

Since Jul 22Pushed 1y ago1 watchersCompare

[ Source](https://github.com/oyeaussie/PHPFirewall)[ Packagist](https://packagist.org/packages/oyeaussie/phpfirewall)[ GitHub Sponsors](https://github.com/sponsors/oyeaussie)[ Fund](https://buymeacoffee.com/oyeaussie)[ RSS](/packages/oyeaussie-phpfirewall/feed)WikiDiscussions main Synced today

READMEChangelog (10)Dependencies (13)Versions (28)Used By (1)

Awards
------

[](#awards)

PHPFirewall was awarded 1st prize in the IP2Location Programming Contest 2024 [IP2Location Programming Contest 2024](https://contest.ip2location.com/winners)

Description:
------------

[](#description)

PHPFirewall is a tool to allow/block connections to your web resource using IP address. The IP address details are either retrieved from local database or by making API calls to IP2Location.io

Why this project?
-----------------

[](#why-this-project)

Internet is ever growing. New devices are coming online everyday which requires the ISPs to add new network range into their system. This makes it quite difficult for firewalls like Cisco or pfsense (linux) to manage policies or know about all networks that are introduced by the ISP of a particular region. Most network hacking happens because of incorrect/failed firewall rules. It's just hard to know all of the network IP ranges of a region.

I wanted to create a firewall application that can be installed on shared hosting, that does not require physical access to the hardware or require a dedicated hardware to run. PHPFirewall can run in a shared hosting environment like Cpanel and it will work just fine. Most Cpanel providers provide access to the users space via SSH, so managing the firewall via CLI is possible.

The whole idea is not to worry about which IP belongs to which part of the world. 1 line should be enough to allow connection from that region and the firewall should take care of the rest of the connections by blocking them. Ip2location.io API along with this application - PHPFirewall, makes this possible.

Code Example:
-------------

[](#code-example)

```
//In index.php
