Download the PHP package sirmonti/doh without Composer

On this page you can find all versions of the php package sirmonti/doh. 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 doh

DOH - DNS over HTTPS client library for PHP

Introduction

DNS resolve is a well known function that is implemented in all operating systems, then, Why we need a different way to do it? The main reason is privacy, standard DNS protocol don't encrypt connections, which means DNS requests can be spied and forged.

But there are other reasons; first, DOH is fast, more fast than a lot of local servers. This is not very surprisingly if you consider that cloudflare and google (the main DOH providers) have huge network infraestructures. But there are more, DOH provides a more descriptive errors. For example, standard DNS servers can misinterpret network errors as nonexistent records. DOH will correctly report the error.

If you need a fast and reliable DNS name resolution, If you need fast and reliable name resolution, more precisely, if you need bulk name resolution, DOH provides a better solution than standard DNS servers.

Complete documentation can be found in the github.io page

Install

Vía composer

Usage

Actually, the library supports two DoH providers, cloudflare and google. The support is implemented across two wrapper classes:

There isn't any differente to use one class or another. The only reason to prefer one or the other is the sympathy you have for the company.

The classes are called statically, there is no need to create an object. For example, if you want to get the IP address for www.google.com using google backend, the call will be:

If you have more sympathy for cloudflare, you can use it as a backend

The classes have the following methods:

function Description
IPtoDNS($ip) Convert an IP address to a DNS encoding valid for PTR querys
dns($name,$type) Resolve a DNS query. $name is the name to resolve and $type is the record type searched
getStatus() Get the status code for the last query

DNS resolution

The method "dns($name,$type)" execute a DNS query. The query return an array with the responses. In case of error the function returns an empty array and set "status" attribute with the error code. The parameters are the name we want resolve and the record type we are asking for.

When parameters have an invalid value, an InvalidValurException will be fired, network or DNS error doesn't fire any exception, error will be reported with an status code.

Valid record types: NS, MX, TXT, A, AAAA, CNAME, SPF, SOA, PTR, SRV, DS, DNSKEY

The response is an array with the returned responses. If the query don't have a valid response or an error ocurrs, the call will return an empty array and set the "status" property to the error code. If all is ok, the status code will be zero.

status code values:

On invalid parameters an InvalidArgumentException will be fired with the status codes 100 or 101.

Examples

The script produces this response

In this example, we use the DOH_PROVIDER constant to set the resolver

The script produces this response

Example for a bogus query. We use the hardcoded default resolver

The script produces this response

LICENSE

This library is licensed under MIT LICENSE


All versions of doh with dependencies

PHP Build Version
Package Version
Requires php Version >=7.4
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 sirmonti/doh contains the following files

Loading the files please wait ....