2017 © Pedro Peláez
 

library laravel-apixu-client

A laravel package to interface with the Apixu API

image

rjvandoesburg/laravel-apixu-client

A laravel package to interface with the Apixu API

  • Friday, May 19, 2017
  • by rjvandoesburg
  • Repository
  • 1 Watchers
  • 0 Stars
  • 61 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 2 Versions
  • 9 % Grown

The README.md

A laravel package to interface with the Apixu API

This package adds a facade and a dependency injectable class you can use to make easy calls to the api, (*1)

Install

You can install the package via composer:, (*2)

``` bash composer require rjvandoesburg/laravel-apixu-client, (*3)


You must install the following service provider: ```php // config/app.php 'providers' => [ ... Rjvandoesburg\Apixu\ApixuServiceProvider::class, ... ];

This package requires an API key that can be stored in the .env file. You can get your key here: https://www.apixu.com/ The following settings are available for your .env file:, (*4)

APIXU_KEY={your-key-here}
APIXU_URL=https://api.apixu.com/v1
APIXU_CACHE_LENGTH=30

The cache length is how long before new data is fetched from the server, this because you might want to limit the API calls, (*5)

These settings are set in a config file that you can edit yourself, should you desire to do so. Execute the following command to get the config file, (*6)

php artisan vendor:publish --provider="Rjvandoesburg\Apixu\ApixuServiceProvider"

A file named apixu.php will be created in the config directory., (*7)

Usage

The API has 4 endpoint * Current * Forecast * History * Search, (*8)

Each request needs certain parameters, read more about those here, (*9)

To build op the filters you need to use a FiltersClass and all parameters you can set for the API are defined as properties. To use the facade to get the current weather, use the following:, (*10)

$filters = new \Rjvandoesburg\Apixu\Filters([
    'q' => 'London',
]);
$response = \Apixu::current($filters);

This will return a CurrentResponse which contains all properties returned. You can use this response to easily output the response., (*11)

The available methods are:, (*12)

\Apixu::current($filters);
\Apixu::forecast($filters);
\Apixu::history($filters);
\Apixu::search($filters);

or use the dependency injection method, (*13)

public function getWeather(\Rjvandoesburg\Apixu\ApixuClient $apixu)
{
    $filters = new \Rjvandoesburg\Apixu\Filters([
        'q' => 'London',
    ]);

    return $apixu->current($filters)
}

Credits

License

The MIT License (MIT). Please see License File for more information., (*14)

The Versions

19/05 2017

dev-master

9999999-dev

A laravel package to interface with the Apixu API

  Sources   Download

MIT

The Requires

  • php >=5.6.0

 

by Robert-John van Doesburg

laravel apixu laravel-5-package

19/05 2017

1.0.0

1.0.0.0

A laravel package to interface with the Apixu API

  Sources   Download

MIT

The Requires

  • php >=5.6.0

 

by Robert-John van Doesburg

laravel apixu laravel-5-package