PHPackages                             knotsphp/flushdns - 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. knotsphp/flushdns

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

knotsphp/flushdns
=================

Flush DNS cache on your system

v1.0.0(1y ago)18MITPHPPHP ^8.2

Since Dec 24Pushed 1y ago1 watchersCompare

[ Source](https://github.com/knotsphp/flushdns)[ Packagist](https://packagist.org/packages/knotsphp/flushdns)[ GitHub Sponsors](https://github.com/SRWieZ)[ RSS](/packages/knotsphp-flushdns/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (1)Dependencies (6)Versions (2)Used By (0)

FlushDNS
========

[](#flushdns)

[![Latest Stable Version](https://camo.githubusercontent.com/18c56295f4954eff0c11ecea5f3f52708aab3b0daf5d32c09796b5fab411b6b2/68747470733a2f2f706f7365722e707567782e6f72672f6b6e6f74737068702f666c757368646e732f76)](https://packagist.org/packages/knotsphp/flushdns)[![Total Downloads](https://camo.githubusercontent.com/7ce0808cd75225a592cf3372ec8aaf7cc4f692c19c569b843fbcccb5fbef28fe/68747470733a2f2f706f7365722e707567782e6f72672f6b6e6f74737068702f666c757368646e732f646f776e6c6f616473)](https://packagist.org/packages/knotsphp/flushdns)[![Latest Unstable Version](https://camo.githubusercontent.com/6e4c1184a4e38ec69744bd59257dc2cd35dfe08c93fb1b91c4b48d670e31ad05/68747470733a2f2f706f7365722e707567782e6f72672f6b6e6f74737068702f666c757368646e732f762f756e737461626c65)](https://packagist.org/packages/knotsphp/flushdns)[![License](https://camo.githubusercontent.com/7b8cfb49bd4cf8ad084f0b804f505a6aae7b88073911fb67ab3e9c38ac23821e/68747470733a2f2f706f7365722e707567782e6f72672f6b6e6f74737068702f666c757368646e732f6c6963656e7365)](https://packagist.org/packages/knotsphp/flushdns)[![PHP Version Require](https://camo.githubusercontent.com/03a9ac22d540656950e59b3bad179b7c055a04e70ad65849c4ac078c0e3595ad/68747470733a2f2f706f7365722e707567782e6f72672f6b6e6f74737068702f666c757368646e732f726571756972652f706870)](https://packagist.org/packages/knotsphp/flushdns)[![GitHub Workflow Status (with event)](https://camo.githubusercontent.com/4ecdd2869cb1e13b711f4f5642b389629e35122d1fccd12c2a005384214d2e17/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f6b6e6f74737068702f666c757368646e732f746573742e796d6c3f6c6162656c3d5465737473)](https://github.com/knotsphp/flushdns/actions/workflows/test.yml)

FlushDNS is a PHP library to flush the DNS cache of the current machine.

It also provides a command line utility: `flushdns`.

Compatible with MacOS, Linux, and Windows.

🚀 Installation
--------------

[](#-installation)

```
composer require knotsphp/flushdns
```

📚 Usage
-------

[](#-usage)

```
use KnotsPHP\FlushDNS\FlushDNS;

// Flush DNS cache
$success = FlushDNS::run();

// Only get the command
$command = FlushDNS::getCommand();

// Check if the command needs elevated privileges
$needsElevation = FlushDNS::needsElevation();
```

This library also comes some helpers fnuctions for Curl:

```
// Get options to ignore dns cache
$flushDnsOptions = FlushDNS::getCurlOpts();

// Make the request
$curl = curl_init();
curl_setopt_array($curl, array_merge(
    [
        CURLOPT_URL => "https://app.unolia.com/api/v1/domains",
        CURLOPT_RETURNTRANSFER => true,
        CURLOPT_HTTPHEADER => [
            "Accept: application/json",
            "Authorization: Bearer 123"
        ],
    ],
    $flushDnsOptions,
));
$response = curl_exec($curl);
$domains = json_decode($response);
curl_close($curl);
```

📚 Use in command line
---------------------

[](#-use-in-command-line)

You can also use this library in the command line by using the `flushdns` command.

It's recommended to install the library globally to use it in the command line.

```
composer global require knotsphp/flushdns
```

Then you can use the `flushdns` command to get the public IP address of the current machine.

```
# In your project directory
vendor/bin/flushdns

# Globally installed
flushdns
```

📖 Documentation
---------------

[](#-documentation)

This library is compatible with MacOS, Linux, and Windows.

Some operating systems may require root access to flush the DNS cache.

📋 TODO
------

[](#-todo)

- Add argument to public static method to get a command for a specific OS. (needs knotsphp/system updated)
- Add support for more operating systems.
- Add support for running elevated commands on MacOS and Linux by passing the password as an argument or having a gui prompt depending of the context. (needs knotsphp/elevated to be written)

🤝 Contributing
--------------

[](#-contributing)

Clone the project and run `composer update` to install the dependencies.

Before pushing your changes, run `composer qa`.

This will run [pint](http://github.com/laravel/pint) (code style), [phpstan](http://github.com/phpstan/phpstan) (static analysis), and [pest](http://github.com/pestphp/pest) (tests).

👥 Credits
---------

[](#-credits)

FlushDNS was created by Eser DENIZ.

📝 License
---------

[](#-license)

FlushDNS is licensed under the MIT License. See LICENSE for more information.

###  Health Score

28

—

LowBetter than 54% of packages

Maintenance40

Moderate activity, may be stable

Popularity6

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity50

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

510d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/735894a4f6e39aa85e3d136abc9cf0be92da593d88731382384185293cbfe965?d=identicon)[SRWieZ](/maintainers/SRWieZ)

---

Top Contributors

[![SRWieZ](https://avatars.githubusercontent.com/u/1408020?v=4)](https://github.com/SRWieZ "SRWieZ (12 commits)")

---

Tags

dnsflushphpclicachednsflush

###  Code Quality

TestsPest

Static AnalysisPHPStan

Code StyleLaravel Pint

Type Coverage Yes

### Embed Badge

![Health badge](/badges/knotsphp-flushdns/health.svg)

```
[![Health](https://phpackages.com/badges/knotsphp-flushdns/health.svg)](https://phpackages.com/packages/knotsphp-flushdns)
```

###  Alternatives

[symfony/console

Eases the creation of beautiful and testable command line interfaces

9.8k1.1B11.3k](/packages/symfony-console)[nunomaduro/collision

Cli error handling for console/command-line PHP applications.

4.6k331.8M8.5k](/packages/nunomaduro-collision)[nunomaduro/termwind

It's like Tailwind CSS, but for the console.

2.5k239.8M286](/packages/nunomaduro-termwind)[wp-cli/wp-cli

WP-CLI framework

5.1k17.2M320](/packages/wp-cli-wp-cli)[wp-cli/php-cli-tools

Console utilities for PHP

68325.0M367](/packages/wp-cli-php-cli-tools)[b13/warmup

This extension adds a CLI script to warmup the caches.

12120.6k](/packages/b13-warmup)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
