Download the PHP package what3words/w3w-php-wrapper without Composer

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

what3words w3w-php-wrapper

A PHP library to use the what3words REST API.

Overview

The what3words PHP wrapper gives you programmatic access to

Authentication

To use this library you’ll need to obtain an API key, please visit https://what3words.com/select-plan and sign up for an account.

Installation

Composer

To use this library in your project, place the following line in your composer.json:

Manual

To manually include this file, place Geocoder.php into your project, and require_once("Geocoder.php")

Initialise

Options

You can also provide header values and referer (for restricted API keys).

Convert To Coordinates

Convert a 3 word address to a position, expressed as coordinates of latitude and longitude.

This function takes the words parameter as a string of 3 words 'table.book.chair'

The returned payload from the convertToCoordinates method is described in the what3words REST API documentation.

Code Example

Convert To 3 Word Address

Convert coordinates, expressed as latitude and longitude to a 3 word address.

The returned payload from the convertTo3wa method is described in the what3words REST API documentation.

Code Example

Available Languages

This function returns the currently supported languages. It will return the two letter code (ISO 639), and the name of the language both in that language and in English.

The returned payload from the convertTo3wa method is described in the what3words REST API documentation

Code Example

Grid Section

Returns a section of the 3m x 3m what3words grid for a given area. The requested box must not exceed 4km from corner to corner, or a BadBoundingBoxTooBig error will be returned. Latitudes must be >= -90 and <= 90, but longitudes are allowed to wrap around 180. To specify a bounding-box that crosses the anti-meridian, use longitude greater than 180. Example value: 50.0, 179.995, 50.01, 180.0005.

The returned payload from the gridSection function is described in the what3words REST API documentation

Code Example

AutoSuggest

Returns a list of 3 word addresses based on user input and other parameters.

This method provides corrections for the following types of input error:

The autoSuggest method determines possible corrections to the supplied 3 word address string based on the probability of the input errors listed above and returns a ranked list of suggestions. This method can also take into consideration the geographic proximity of possible corrections to a given location to further improve the suggestions returned.

Input 3 word address

You will only receive results back if the partial 3 word address string you submit contains the first two words and at least the first character of the third word; otherwise an error message will be returned.

Clipping and Focus

We provide various clip policies to allow you to specify a geographic area that is used to exclude results that are not likely to be relevant to your users. We recommend that you use the clipping to give a more targeted, shorter set of results to your user. If you know your user’s current location, we also strongly recommend that you use the focus to return results which are likely to be more relevant.

In summary, the clip policy is used to optionally restrict the list of candidate AutoSuggest results, after which, if focus has been supplied, this will be used to rank the results in order of relevancy to the focus.

The returned payload from the autosuggest method is described in the what3words REST API documentation.

Usage

The first parameter is the partial three words, or voice data. It is followed by an array of AutoSuggestOption objects. The last parameter is the completion block. The AutoSuggestOption objects in the array are created using static convenience functions of the form:

Code Example #1

Code Example #2

Focus on (51.4243877,-0.34745) and look for 6 results.

Code Example #3

Validate what3words

Handling Errors

All the functions will return an stdClass Object containing the requested data, or on failure, they will return false. If false is returned, call get_error(), and it will return an associative array containing a code value and a message value.

Error values are listed in the what3words REST API documentation.

Development (using Docker)

You can see w3w-php-wrapper in action by running docker compose watch (make sure you're running this from the development directory) and open http://localhost:9000 on your browser. Any changes you make to the source code will be reloaded as you refresh your browser, just ensure you have loaded your environment variable named: W3W_API_KEY by running export W3W_API_KEY=<YOUR_API_KEY>.

Running tests (using Docker)

Once you've spin up the container, you can run docker exec php-server /var/www/html/vendor/bin/phpunit to execute the unit tests.


All versions of w3w-php-wrapper with dependencies

PHP Build Version
Package Version
Requires php Version >=5.6
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 what3words/w3w-php-wrapper contains the following files

Loading the files please wait ....