Download the PHP package hi-folks/milk-sdk-php without Composer
On this page you can find all versions of the php package hi-folks/milk-sdk-php. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download hi-folks/milk-sdk-php
More information about hi-folks/milk-sdk-php
Files in hi-folks/milk-sdk-php
Package milk-sdk-php
Short Description Milk SDK PHP is a (fluent) open-source PHP library that makes it easy to integrate your PHP application with location services
License MIT
Homepage https://github.com/hi-folks/milk-sdk-php
Informations about the package milk-sdk-php
Milk SDK PHP
Milk SDK PHP is a (fluent) open-source PHP library that makes it easy to integrate your PHP application with location services like:
- V7: for calculate routes from a starting point to destination;
- HERE Weather Destination API: for getting weather forecasts;
- HERE Geocoding API: for converting addresses into geographic coordinates;
- HERE Reverse Geocoding API: for converting coordinates into addresses;
- HERE Isoline API: for calculating the area that a driver (or a biker or a walker) can reach within a given time or distance;
- HERE Discover API: for searching addresses, places and locations;
- HERE Map Image API: for creating static image of a map;
- HERE Data Hub API;
- ... other coming soon ...
Getting Started
Install the SDK
In your PHP project install package via Composer:
Obtain HERE API Key
To use HERE Location Services you will need an API key. The API key is a unique identifier that is used to authenticate API requests associated with your project. There is a official tutorial for retrieving the API Key: https://developer.here.com/tutorials/getting-here-credentials/
Weather API
With Weather API class you can get weather forecasts, observation, or alerts for a specific location.
You can call the following methods to get the corresponding weather information:
- productObservation(): Get current weather conditions from the eight closest locations to the specified location.
- productAlerts(): Get forecasted weather alerts for the next 24 hours.
- productForecast7days(): Get morning, afternoon, evening and night weather forecasts for the next seven days.
- productForecast7daysSimple(): Get daily weather forecasts for the next seven days.
- productForecastAstronomy(): Get information on when the sun and moon rise and set, and on the phase of the moon for the next seven days.
- productForecastHourly(): Get hourly weather forecasts for the next seven days.
- productNwsAlerts(): Get all active watches and warnings for the US and Canada.
For example, to retrieve weather forecasts in Berlin:
Routing API (v7)
To retrieve the fastest route by foot
Instead of using get(), you could use getManeuverInstructions() method:
Routing API (v8)
To retrieve the fastest route by car
Geocoding API
In order to retrieve geo-coordinates (latitude, longitude) of a known address or place.
Reverse Geocoding API
In order to find the nearest address to specific geo-coordinates:
Isoline API
Map Image Api
With MapImage class you can create static image of a map. For the map you can define:
- center(): the center of the map;
- addPoi(): add a point in the map;
- zoom(): set the zoom level;
- height(): set the height of image (in pixel);
- width(): set the width of the image (in pixel).
You can use also the Geocoding functionality with centerAddress() method.
Discover API
If you need to search an address or a place and you need to validate it and obtain some other information about the location, you can use Discover API endpoint via Discover class.
If you need to search an address in Italy, you can use inItaly() method:
Use HERE Data Hub
Configuring XYZ HUB
With this SDK you can consume DataHub (XYZ) API. You have 2 options:
- use your own instance of XYZ HUB or
- use Data Hub Cloud https://developer.here.com/documentation/studio/map_customization_suite_hlp/dev_guide/index.html
Configure SDK with your own instance of XYZ HUB
Running your own instance of XYZ HUB means that you already have your instance of https://github.com/heremaps/xyz-hub. A tutorial about how to set up XYZ Hub locally (on localhost): https://dev.to/robertobutti/restful-web-service-for-geospatial-data-12ii
Create a .env file. Fill it with:
Configure SDK with XYZ HUB Cloud service
Using XYZ HUB Cloud Service means that you are using this host https://xyz.api.here.com.
To use this service you need to sign in as developer on https://developer.here.com/ and create your plan (for example Freemium) and obtain your Access Token.
Once you have your access token, create a .env file. You can start from a sample file (.env.dist):
Then, you need to fill your XYZ_ACCESS_TOKEN in .env file with your access token.
Quick Examples
In order to use the Milk SDK, you need to:
- create a PHP file
- include the autoload.php file
- declare all imports via use
- load environment configuration (via Dotenv)
- get your token
- get your XYZ Spaces
- display your result
Retrieve your XYZ Spaces
To get your XYZ Spaces:
To get XYZ Spaces by everybody (not only your own XYZ Spaces):
Delete Space
To delete a XYZ Space:
Create Space
To create a new XYZ Space:
Update Space
To update the XYZ Space with space id == \$spaceId:
Statistics
The get statistics from XYZ Space:
Features
Iterate features
Retrieve 1 Feature
You need to use feature() method with $featureId and $spaceId
Create or Edit 1 Feature
To create or edit a Feature you can use saveOne() method.
Create multiple features from a geojson file
If you have a Geojson File, you can upload it into a space.
Search features by property
To search features by properties you can use addSearchParams to add serach params, in the example below, you are searching features with name property equals "Colosseo".
Search features by proximity
To search feature close to latitude=41.890251 and longitude=12.492373 with a radius less than 1000 meters (close to Colosseum):
Useful reference
Data Hub API
- ReDoc API documentation: https://xyz.api.here.com/hub/static/redoc/
- Open API documentation: https://xyz.api.here.com/hub/static/swagger/
HERE Destination Weather API
- Overview: https://developer.here.com/documentation/destination-weather/dev_guide/topics/overview.html
- API Reference: https://developer.here.com/documentation/destination-weather/dev_guide/topics/api-reference.html
HERE Rest Routing V8 API
- Overview: https://developer.here.com/documentation/routing-api/8.9.1/dev_guide/topics/use-cases/calculate-route.html
- API Reference: https://developer.here.com/documentation/routing-api/8.9.1/api-reference-swagger.html
HERE Rest Geocoding API
HERE Rest Reverse Geocoding API
HERE Rest Isoline API
All versions of milk-sdk-php with dependencies
ext-json Version *
guzzlehttp/guzzle Version ^6.3|^7.0
jmikola/geojson Version ^1.0
rozklad/heremaps-flexible-polyline Version ^1.0
vlucas/phpdotenv Version ^3.3|^4.0|^5.2