https://github.com/knotsphp/flushdns
Flush DNS cache on your system
https://github.com/knotsphp/flushdns
dns flush php
Last synced: 4 months ago
JSON representation
Flush DNS cache on your system
- Host: GitHub
- URL: https://github.com/knotsphp/flushdns
- Owner: knotsphp
- License: mit
- Created: 2024-12-23T23:00:17.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2024-12-24T21:36:06.000Z (over 1 year ago)
- Last Synced: 2025-09-06T17:45:40.349Z (10 months ago)
- Topics: dns, flush, php
- Language: PHP
- Homepage: https://srwiez.com/open-source
- Size: 19.5 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Funding: .github/FUNDING.yml
- License: LICENSE
Awesome Lists containing this project
README
# FlushDNS
[](https://packagist.org/packages/knotsphp/flushdns)
[](https://packagist.org/packages/knotsphp/flushdns)
[](https://packagist.org/packages/knotsphp/flushdns)
[](https://packagist.org/packages/knotsphp/flushdns)
[](https://packagist.org/packages/knotsphp/flushdns)
[](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
```bash
composer require knotsphp/flushdns
```
## 📚 Usage
```php
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:
```php
// 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
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.
```bash
composer global require knotsphp/flushdns
```
Then you can use the `flushdns` command to get the public IP address of the current machine.
```bash
# In your project directory
vendor/bin/flushdns
# Globally installed
flushdns
```
## 📖 Documentation
This library is compatible with MacOS, Linux, and Windows.
Some operating systems may require root access to flush the DNS cache.
## 📋 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
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
FlushDNS was created by Eser DENIZ.
## 📝 License
FlushDNS is licensed under the MIT License. See LICENSE for more information.