Skip to content

Commit 355714d

Browse files
authored
Merge pull request #33 from programmatordev/1.x
1.x
2 parents 0450abc + 01c5617 commit 355714d

File tree

85 files changed

+5721
-7
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

85 files changed

+5721
-7
lines changed

.gitignore

+7-5
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
1-
composer.phar
1+
/composer.lock
2+
/composer.phar
3+
/phpunit.xml
4+
/.phpunit.result.cache
25
/vendor/
3-
4-
# Commit your application's lock file https://getcomposer.org/doc/01-basic-usage.md#commit-your-composer-lock-file-to-version-control
5-
# You may choose to ignore a library lock file http://getcomposer.org/doc/02-libraries.md#lock-file
6-
# composer.lock
6+
/logs/
7+
/.idea
8+
/index.php

LICENSE

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
MIT License
22

3-
Copyright (c) 2023 notprogrammator
3+
Copyright (c) 2023 programmatordev
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

README.md

+67-1
Original file line numberDiff line numberDiff line change
@@ -1 +1,67 @@
1-
# openweathermap-php-api
1+
# OpenWeatherMap PHP API
2+
3+
OpenWeatherMap PHP library that provides convenient access to the OpenWeatherMap API.
4+
5+
Supports [PSR-18 HTTP clients](https://www.php-fig.org/psr/psr-18), [PSR-17 HTTP factories](https://www.php-fig.org/psr/psr-17), [PSR-6 caches](https://www.php-fig.org/psr/psr-6) and [PSR-3 logs](https://www.php-fig.org/psr/psr-3).
6+
7+
## Requirements
8+
9+
- PHP 8.1 or higher.
10+
11+
## API Key
12+
13+
A key is required to be able to make requests to the API.
14+
You must sign up for an [OpenWeatherMap account](https://openweathermap.org/appid#signup) to get one.
15+
16+
## Installation
17+
18+
You can install the library via [Composer](https://getcomposer.org/):
19+
20+
```bash
21+
composer require programmatordev/openweathermap-php-api
22+
```
23+
24+
To use the library, use Composer's [autoload](https://getcomposer.org/doc/01-basic-usage.md#autoloading):
25+
26+
```php
27+
require_once 'vendor/autoload.php';
28+
```
29+
30+
## Basic Usage
31+
32+
Simple usage looks like:
33+
34+
```php
35+
use ProgrammatorDev\OpenWeatherMap\Config;
36+
use ProgrammatorDev\OpenWeatherMap\OpenWeatherMap;
37+
38+
// Initialize
39+
$openWeatherMap = new OpenWeatherMap(
40+
new Config([
41+
'applicationKey' => 'yourappkey'
42+
])
43+
);
44+
45+
// Get current weather by coordinate (latitude, longitude)
46+
$currentWeather = $openWeatherMap->getWeather()->getCurrent(50, 50);
47+
// Show current temperature
48+
echo $currentWeather->getTemperature();
49+
```
50+
51+
## Documentation
52+
53+
- [Usage](docs/01-usage.md)
54+
- [Configuration](docs/02-configuration.md)
55+
- [Supported APIs](docs/03-supported-apis.md)
56+
- [Error Handling](docs/04-error-handling.md)
57+
- [Objects](docs/05-objects.md)
58+
59+
## Contributing
60+
61+
Any form of contribution to improve this library will be welcome and appreciated.
62+
Make sure to open a pull request or issue.
63+
64+
## License
65+
66+
This project is licensed under the MIT license.
67+
Please see the [LICENSE](LICENSE) file distributed with this source code for further information regarding copyright and licensing.

composer.json

+56
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
{
2+
"name": "programmatordev/openweathermap-php-api",
3+
"description": "OpenWeatherMap PHP library that provides convenient access to the OpenWeatherMap API",
4+
"type": "library",
5+
"keywords": ["OpenWeatherMap", "API", "PHP", "SDK", "PSR-18", "PSR-17", "PSR-6", "PSR-3"],
6+
"license": "MIT",
7+
"authors": [
8+
{
9+
"name": "André Pimpão",
10+
"email": "a.pimpao@programmator.dev",
11+
"homepage": "https://programmator.dev/"
12+
}
13+
],
14+
"require": {
15+
"php": ">=8.1",
16+
"php-http/cache-plugin": "^1.8",
17+
"php-http/client-common": "^2.7",
18+
"php-http/discovery": "^1.18",
19+
"php-http/logger-plugin": "^1.3",
20+
"psr/cache": "^2.0 || ^3.0",
21+
"psr/http-client": "^1.0",
22+
"psr/http-factory": "^1.0",
23+
"psr/log": "^2.0 || ^3.0",
24+
"symfony/options-resolver": "^6.3"
25+
},
26+
"require-dev": {
27+
"monolog/monolog": "^3.4",
28+
"nyholm/psr7": "^1.8",
29+
"php-http/mock-client": "^1.6",
30+
"phpunit/phpunit": "^10.0",
31+
"symfony/cache": "^6.3",
32+
"symfony/http-client": "^6.3",
33+
"symfony/var-dumper": "^6.3"
34+
},
35+
"provide": {
36+
"psr/http-client-implementation": "1.0",
37+
"psr/http-factory-implementation": "1.0"
38+
},
39+
"autoload": {
40+
"psr-4": {
41+
"ProgrammatorDev\\OpenWeatherMap\\": "src/"
42+
}
43+
},
44+
"autoload-dev": {
45+
"psr-4": {
46+
"ProgrammatorDev\\OpenWeatherMap\\Test\\": "tests/"
47+
}
48+
},
49+
"config": {
50+
"optimize-autoloader": true,
51+
"sort-packages": true,
52+
"allow-plugins": {
53+
"php-http/discovery": true
54+
}
55+
}
56+
}

docs/01-usage.md

+50
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
# Using OpenWeatherMap PHP API
2+
3+
- [Requirements](#requirements)
4+
- [API Key](#api-key)
5+
- [Installation](#installation)
6+
- [Basic Usage](#basic-usage)
7+
8+
## Requirements
9+
10+
- PHP 8.1 or higher.
11+
12+
## API Key
13+
14+
A key is required to be able to make requests to the API.
15+
You must sign up for an [OpenWeatherMap account](https://openweathermap.org/appid#signup) to get one.
16+
17+
## Installation
18+
19+
You can install the library via [Composer](https://getcomposer.org/):
20+
21+
```bash
22+
composer require programmatordev/openweathermap-php-api
23+
```
24+
25+
To use the library, use Composer's [autoload](https://getcomposer.org/doc/01-basic-usage.md#autoloading):
26+
27+
```php
28+
require_once 'vendor/autoload.php';
29+
```
30+
31+
## Basic Usage
32+
33+
Simple usage looks like:
34+
35+
```php
36+
use ProgrammatorDev\OpenWeatherMap\Config;
37+
use ProgrammatorDev\OpenWeatherMap\OpenWeatherMap;
38+
39+
// Initialize
40+
$openWeatherMap = new OpenWeatherMap(
41+
new Config([
42+
'applicationKey' => 'yourappkey'
43+
])
44+
);
45+
46+
// Get current weather by coordinate (latitude, longitude)
47+
$currentWeather = $openWeatherMap->getWeather()->getCurrent(50, 50);
48+
// Show current temperature
49+
echo $currentWeather->getTemperature();
50+
```

0 commit comments

Comments
 (0)