Download the PHP package davidhirtz/yii2-location-google without Composer

On this page you can find all versions of the php package davidhirtz/yii2-location-google. 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 yii2-location-google

yii2-location-google

Google Places provider for the Yii 2 extension yii2-location: the admin's location form searches the Places API (New) for a place and fills the location's address, name and coordinates from the place a user picks. Requires davidhirtz/yii2-location and davidhirtz/yii2-skeleton, plus Guzzle and ramsey/uuid.

Installation

The bundle bootstraps itself through extra.bootstrap and ships no migrations, no module and no message files. Enable the Places API (New) in the Google Cloud Console, create an API key for it and set googleApiKey in config/params.php; then nothing else has to run.

Configuration

params.googleApiKey

The bundle does nothing without it. Bootstrap registers the @location-google alias and returns when params.googleApiKey is missing or empty, so the location form keeps the plain provider_id input of yii2-location. With a key set it wires three things:

Components\GoogleMapsApi

The API client is built through the container (GoogleMapsApi::create()), and Bootstrap merges apiKey into whatever definition a project registered, without overwriting one it names itself.

Property Default Meaning
apiKey params.googleApiKey Sent as X-Goog-Api-Key; init() throws an InvalidConfigException without one
languageCode Yii::$app->language Language of the suggestions and place details, mapped through supportedLanguageCodes
supportedLanguageCodes en-US, de, fr, pt, zh-CN, zh-TW Map of application language to Places API language code; an unmapped language falls back to en
handlerStack HandlerStack::create() Guzzle handler stack; in debug mode every request is logged through Yii::info()
timeout 10 Connect and response timeout in seconds; a failed request throws a 502 HttpException

An autocomplete request opens a Places session token, kept in the web session under GoogleMapsApi::SESSION_TOKEN_KEY, and the place details request that follows closes it, so the two are billed as one session. Under the console application there is no session and no token.

Components\Autocomplete

Autocomplete::$options are Guzzle request options merged into every autocomplete call; the request body is the json key, so a project restricts the suggestions there:

Components\PlaceDetails

PlaceDetails::$fields names the Places API fields requested for a picked place and decides which location attributes are written. The default is id, formattedAddress, addressComponents, location and displayName; PlaceDetails::$options are Guzzle request options for that call. A field left out of the list is neither requested nor written, so a project that keeps the name a user typed drops displayName:

Places API field Location attribute
id provider_id
formattedAddress formatted_address
location.latitude / location.longitude lat / lng
displayName.text name
addressComponents street_number house_number
addressComponents route street
addressComponents sublocality_level_1 district
addressComponents locality locality
addressComponents postal_code postal_code
addressComponents administrative_area_level_1 state
addressComponents country (short text) country_code

A component of any other type is ignored.


All versions of yii2-location-google with dependencies

PHP Build Version
Package Version
Requires php Version ^8.3
davidhirtz/yii2-location Version ^3.0
davidhirtz/yii2-skeleton Version ^3.18
guzzlehttp/guzzle Version ^7.9
ramsey/uuid Version ^4.7
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 davidhirtz/yii2-location-google contains the following files

Loading the files please wait ...