rovast/weather

A weather SDK based on Amap

v0.0.1 2018-11-05 08:47 UTC

This package is auto-updated.

Last update: 2024-09-29 05:02:12 UTC


README

Build Status StyleCI build status

基于高德开放平台的天气 API 集成

此项目为测试项目,来自 Laravel-China《PHP 扩展包实战教程 - 从入门到发布》 是个练习项目,请不要用于生产环境

安装

$ composer require rovast/weather -vvv

使用

use Rovast\Weather\Weather;

$key = 'your-api-key';

$weather = new Weather($key);

在 Laravel 中使用

config/services.php 中配置

'weather' => [
    'key' => env('WEATHER_API_KEY', 'your-api-key'),
],

两种方式调用

方法参数注入

public function edit(Weather $weather) 
{
    $response = $weather->getWeather('深圳');
}

服务名访问

public function edit() 
{
    $response = app('weather')->getWeather('深圳');
}

License

MIT