rovast / weather
A weather SDK based on Amap
v0.0.1
2018-11-05 08:47 UTC
Requires
- ext-json: *
- guzzlehttp/guzzle: ^6.3
- mockery/mockery: ^1.2
- phpunit/phpunit: ^7.4
This package is auto-updated.
Last update: 2025-04-29 01:00:11 UTC
README
基于高德开放平台的天气 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