Download the PHP package knotsphp/publicip without Composer

On this page you can find all versions of the php package knotsphp/publicip. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package publicip

PublicIP

Latest Stable Version Total Downloads Latest Unstable Version License PHP Version Require GitHub Workflow Status (with event)

A simple PHP library to get your public IP address reliably and fast.

This library uses dig or HTTP requests to obtain the public IP address of the current machine by utilizing publicly available whoami services.

It comes with an opinionated default configuration to use the fastest and most reliable fetchers and providers. However, it also includes a flexible API that allows you to use different fetchers and different providers.

🚀 Installation

📚 Usage

Easiest way to get the public IP address of the current machine is to use the PublicIP::get() method.

These methods return the IP address as a string or null if the fetcher fails. No exceptions are thrown.

If you want to use a specific fetcher, or a specific provider, you can use the PublicIPv4::finder()->fetch() method.

This method gives you more control, but you will need to manage exceptions on your own.

Advanced Usage

You can also use a Fetcher directly to get the IP address.

Note that this returns null instead of throwing an exception if the fetcher fails.

📚 Use in command line

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

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

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

🏃 Performance

If you are sure that your machine has dig installed, you can speed up the process by setting the isSupported property to true.

It works both ways; if you are sure that your machine does not have dig installed, you can set it to false to prevent unnecessary checks.

If you use the CurlFetcher or FileGetContentsFetcher, you can set the forceHTTP property to true to use HTTP instead of HTTPS. Some whoami services do not support HTTPS anyway as they are meant to be used in scripts like this curl ifconfig.co.

📖 Documentation

dig provider list

IP4or6 IPv4 IPv6 Reliable?
Cloudflare
Google
OpenDNS ⚠️ says they have blocked France & Portugal but seems to work in France in my testings
Akamai ⚠️ ⚠️ ⚠️ ⚠️ last digits of the IP can be wrong

HTTP whoami provider list

IPv4 IPv6 IP4or6 Note
ifconfig.co Fast
ipify.org Open-source
ifconfig.me
icanhazip.com
cloudflare.com Use more data
ipinfo.io ⚠️ only IPv4
amazonaws.com ⚠️ only IPv4

📋 TODO

Contributions are welcome!

🤝 Contributing

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

Before pushing your changes, run composer qa.

This will run pint (code style), phpstan (static analysis), and pest (tests).

📦 Alternatives

If you are not pleased with this library, check out the following alternatives:

You can also contribute to this library by opening an issue or a pull request.

👥 Credits

PublicIP was created by Eser DENIZ.

📝 License

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


All versions of publicip with dependencies

PHP Build Version
Package Version
Requires php Version ^8.3
ext-curl Version *
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package knotsphp/publicip contains the following files

Loading the files please wait ....