Download the PHP package philwc/dark-sky without Composer
On this page you can find all versions of the php package philwc/dark-sky. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download philwc/dark-sky
More information about philwc/dark-sky
Files in philwc/dark-sky
Package dark-sky
Short Description A strongly typed simple client to talk to the Dark Sky API.
License MIT
Informations about the package dark-sky
Dark Sky API Client
A strongly typed simple client to talk to the Dark Sky API.
Getting Started
To get started, you will need to get a secret key from Dark Sky: https://darksky.net/dev/account.
Client Adapters
This package makes use of HTTP adapters to connect to the API. Two are included out of the box,
a Guzzle adapter and a Simple adapter (using file_get_contents
). If you have specialised
connection needs, simply implement the ClientAdapterInterface
and pass to the client factory.
If a ClientAdapter is not specified, the package will make use of the GuzzleAdapter
if
Guzzle is available, falling back to the SimpleAdapter
(using file_get_contents
)
if not.
If a guzzle adapter is provided (or the implemented ClientAdapterInterface
supports it), multiple
requests will be made concurrently.
Usage
Install the package using composer:
Simple Usage
Client
To use the Client
use the ClientFactory
:
Advanced Usage
It is possible to pass both a PSR-16 cache adapter, as well as a PSR-3 logger into the ClientFactory
:
When creating your request, you can pass a parameters
key
to customise the values you get back from DarkSky.
Caching
This package is also able to make use of a PSR-16 caching adapter to cache calls from the API. Simply pass a relevant cache service (see https://packagist.org/providers/psr/simple-cache-implementation) to the client factory to use. No caching is provided out of the box.
It is possible to set the TTL for the cache independently for each request type. On the client,
use setForecastTTL
or setTimeMachineTTL
to specify. By default, the following TTLs are set:
ForecastClient
- 60sTimeMachineClient
- 86400s (24 hours)
Concurrent Requests
It is possible to make concurrent requests to the DarkSky API. Simply create a
RequestCollection
and pass to retrieve
All versions of dark-sky with dependencies
ext-json Version *
php-ds/php-ds Version ^1.2
beberlei/assert Version ^3.0
guzzlehttp/psr7 Version ^1.4
psr/simple-cache Version ^1.0
psr/log Version ^1.0