j-crowe/open-weather
Composer 安装命令:
composer require j-crowe/open-weather
包简介
A very simple wrapper for Open Weather
README 文档
README
PHP Wrapper for the Open Weather API
This library does not require Laravel; however, a Laravel Service Provider is included.
Installation
Install using composer:
"require": {
"j-crowe/open-weather": "1.2"
}
or via CLI
composer require j-crowe/open-weather 1.2
Configuration
There are 3 required configurations:
First, the app_id - an environment variable named 'OPENWEATHER_APPID' that must be set in your application
Please see here to get one
The other two - the Base URL and Default Guzzle Options.
Please see here for possible options
Usage Without Laravel
See below for sample initialization code:
<?php
include_once 'vendor/autoload.php';
use JCrowe\OpenWeather\OpenWeather;
// Note the configs that are required. Guzzle Opts are default options for Guzzle
$baseUrl = 'http://api.openweathermap.org';
$guzzleOpts = array(
'timeout' => 3,
'connect_timeout' => 3
);
$appId = 'abcdefghijklmnop1234567890';
$openWeather = OpenWeather::getInstance($guzzleOpts, $baseUrl, $appId);
$response = $openWeather->getByCityName('los angeles');
if($response->isValid()) {
print_r($response->getWeatherData());
}
?>
Usage With Laravel
In config/app.php, add the following to the service providers array.
array(
...
'JCrowe\OpenWeather\Providers\OpenWeatherServiceProvider',
)
Then add the following to the aliases array.
'OpenWeather' => 'JCrowe\OpenWeather\Facades\OpenWeather'
Publish the configs using php artisan config:publish j-crowe/open-weather, which should include the default configuration, which should include the default configuration.
j-crowe/open-weather 适用场景与选型建议
j-crowe/open-weather 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 18.48k 次下载、GitHub Stars 达 4, 最近一次更新时间为 2014 年 05 月 29 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 j-crowe/open-weather 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 j-crowe/open-weather 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 18.48k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 4
- 点击次数: 1
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2014-05-29