2017 © Pedro Peláez
 

library php-http

PHP HTTP Utilities

image

hugsbrugs/php-http

PHP HTTP Utilities

  • Monday, July 24, 2017
  • by hugsbrugs
  • Repository
  • 1 Watchers
  • 0 Stars
  • 180 Installations
  • HTML
  • 3 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 2 Versions
  • 13 % Grown

The README.md

php-http

This library provides PHP utilities functions to manage URLs. Read PHP DOC, (*1)

Build Status Coverage Status, (*2)

Install

Install package with composer, (*3)

composer require hugsbrugs/php-http

In your PHP code, load librairy, (*4)

require_once __DIR__ . '/../vendor/autoload.php';
use Hug\Http\Http as Http;

Usage

Execute shell nslookup command, (*5)

Http::nslookup($url);

Check if an url is accessible (means not a 404), (*6)

Http::is_url_accessible($url);

Returns HTTP code for given URL, (*7)

Http::get_http_code($url);

Cleans an url from its query parameters, (*8)

Http::url_remove_query($url);

Cleans an url from its query parameters and path, (*9)

Http::url_remove_query_and_path($url);

Quick and dirty function to save an image from the internet, (*10)

Http::grab_image($url, $save_to);

Returns basic HTTP headers for a CURL request, (*11)

Http::get_default_headers($host);

Extracts suffix, tld, domain and subdomain from an URL, (*12)

Http::extract_all_from_url($url);

Extracts extention from an URL, (*13)

Http::extract_extension_from_url($url);

Extracts scheme (ftp, http) from an URL, (*14)

Http::extract_scheme_from_url($url);

Extracts a TLD (Top Level Domain) from an URL, (*15)

Http::extract_tld_from_url($url);

Extracts a sub domain from an URL, (*16)

Http::extract_subdomain_from_url($url);

Extracts a domain name from an URL, (*17)

Http::extract_domain_from_url($url);

Separates Headers from Body in CURL response, (*18)

Http::extract_request_headers_body($html_with_headers);

Sets a php script desired status code (usefull for API), (*19)

Http::header_status($statusCode);

Gets the address and/or http code that the provided URL redirects to. $return can be : url/code/all, (*20)

Http::get_redirect_url($url, $timeout = 5, $return = 'url');

Follows and collects all redirects, in order, for the given URL., (*21)

Http::get_all_redirects($url);

Gets the address and/or http code that the URL ultimately leads to. $return can be : url/code/all, (*22)

Http::get_final_url($url, $return = 'url');

Check a TXT record in domain zone file, (*23)

Http::check_txt_record($domain, $txt);

Waits and tests every minute if domain zone has correct IP adress and TXT record set, (*24)

Http::wait_for_zone_ok($domain, $ip, $txt_record, $wait_minutes = 15);

Tests if domain zone has correct IP adress and TXT record set, (*25)

Http::is_zone_ok($domain, $ip, $txt_record);

Get name servers of given domain, (*26)

Http::get_name_servers('maugey.fr');

Add escaped fragment to URL, (*27)

Http::add_escaped_fragment($url);

To enable CORS, put this line at top of your PHP script, (*28)

Http::cors();

Converts an URL to a filename It does not encode URL parameters (only scheme - domain - folders - file), (*29)

Http::url_2_filename($url);

Dependecies

https://github.com/jeremykendall/php-domain-parser https://github.com/jeremykendall/php-domain-parser/tree/5.7.0 https://publicsuffix.org/list/public_suffix_list.dat, (*30)

Unit Tests

composer exec phpunit
phpunit --configuration phpunit.xml

Author

Hugo Maugey Webmaster | Consultant SEO | Fullstack developer, (*31)

The Versions

24/07 2017

dev-master

9999999-dev

PHP HTTP Utilities

  Sources   Download

The Requires

 

The Development Requires

15/03 2017

v1.0

1.0.0.0

PHP HTTP Utilities

  Sources   Download

The Requires

 

The Development Requires