Download the PHP package mattwright/urlresolver without Composer

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

Welcome to URLResolver.php

URLResolver.php is a PHP class that attempts to resolve URLs to a final, canonical link. On the web today, link shorteners, tracking codes and more can result in many different links that ultimately point to the same resource. By following HTTP redirects and parsing web pages for open graph and canonical URLs, URLResolver.php attempts to solve this issue.

Patterns Recognized

I am open to additional suggestions for improvement.

Usage

Resolving a URL can be as easy as:

If you installed this library using composer, you would change the first line above to:

However, in most cases you will want to perform a little extra setup. The following code sets a user agent to identify your crawler (otherwise the default will be used) and also designates a temporary file that can be used for storing cookies during the session. Some web sites will test the browser for cookie support, so this will enhance your results.

Installation and Requirements

License

URLResolver.php is licensed under the MIT License, viewable in the source code.

Install with Composer

composer require mattwright/urlresolver

Download

URLResolver.php as a .tar.gz or .zip file.

Requirements

API

URLResolver()

$resolver = new mattwright\URLResolver();
Create the URL resolver object that you call additional methods on.

$resolver->resolveURL($url);
$url is the link you want to resolve.
Returns a [URLResult] object that contains the final, resolved URL.

$resolver->setUserAgent($user_agent);
Pass in a string that is sent to each web server to identify your crawler.

$resolver->setCookieJar($cookie_file); # Defaults to disable cookies
This file will be removed at the end of each resolveURL() call.
Pass in the path to a file used to store cookies during each resolveURL() call.
If no cookie file is set, cookies will be disabled and results may suffer.
This file must not already exist. If it does, pass true as second argument to enable overwrite.

$resolver->setMaxRedirects($max_redirects); # Defaults to 10
Set the maximum number of URL requests to attempt during each resolveURL() call.

$resolver->setMaxResponseDataSize($max_bytes); # Defaults to 120000
Pass in an integer specifying the maximum data to download per request.
Multiple URL requests may occur during each resolveURL() call.
Setting this too low may limit the usefulness of results (default 120000).

$resolver->setRequestTimeout($num_seconds); # Defaults to 30
Set the maximum amount of time, in seconds, any URL request can take.
Multiple URL requests may occur during each resolveURL() call.

$resolver->setPreferCanonicalURL($value); # Defaults to false
Set $value to true to prioritize canonical URL over Open Graph URL.

$resolver->isDebugMode($value); # Defaults to false
Set $value to true to enable debug mode and false to disable (the default).
This will print out each link visited, along with status codes and link types.

URLResolverResult()

$url_result = $resolver->resolveURL($url);
Retrieve the URLResolverResult() object representing the resolution of $url.

$url_result->getURL();
This is the best resolved URL we could obtain after following redirects.

$url_result->getHTTPStatusCode();
Returns the integer HTTP status code for the resolved URL.
Examples: 200 - OK (success), 404 - Not Found, 301 - Moved Permanently, ...

$url_result->hasSuccessHTTPStatus();
Returns true if the HTTP status code for the resolved URL is 200.

$url_result->hasRedirectHTTPStatus();
Returns true if the HTTP status code for the resolved URL is 301, 302, or 303.

$url_result->getContentType();
Returns the value of the Content-Type HTTP header for the resolved URL.
If header not provided, null is returned. Examples: text/html, image/jpeg, ...

$url_result->getContentLength();
Returns the size of the fetched URL in bytes for the resolved URL.
Determined only by the Content-Length HTTP header. null returned otherwise.

$url_result->isOpenGraphURL();
Returns true if resolved URL was marked as the Open Graph URL (og:url)

$url_result->isCanonicalURL();
Returns true if resolved URL was marked as the Canonical URL (rel=canonical)

$url_result->isStartingURL();
Returns true if resolved URL was also the URL you passed to resolveURL().

$url_result->didErrorOccur();
Returns true if an error occurred while resolving the URL.
If this returns false, $url_result is guaranteed to have a status code.

$url_result->getErrorMessageString();
Returns an explanation of what went wrong if didErrorOccur() returns true.

$url_result->didConnectionFail();
Returns true if there was a connection error (no header or no body returned).
May indicate a situation where you are more likely to try at least once more.
If this returns true, didErrorOccur() will true as well.

Changelog


All versions of urlresolver with dependencies

PHP Build Version
Package Version
Requires php Version >=5.3
ext-curl Version *
ext-mbstring 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 mattwright/urlresolver contains the following files

Loading the files please wait ....