Skip to content

Commit 01c5617

Browse files
authored
Merge pull request #32 from programmatordev/OPA-13-create-documentation
Create documentation
2 parents 89da479 + 8b26c9d commit 01c5617

26 files changed

+1227
-136
lines changed

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

+10-9
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
{
22
"name": "programmatordev/openweathermap-php-api",
3-
"description": "OpenWeatherMap PHP API library.",
3+
"description": "OpenWeatherMap PHP library that provides convenient access to the OpenWeatherMap API",
44
"type": "library",
5-
"keywords": ["OpenWeatherMap", "API", "PHP"],
5+
"keywords": ["OpenWeatherMap", "API", "PHP", "SDK", "PSR-18", "PSR-17", "PSR-6", "PSR-3"],
66
"license": "MIT",
77
"authors": [
88
{
99
"name": "André Pimpão",
10-
"email": "[email protected]"
10+
"email": "[email protected]",
11+
"homepage": "https://programmator.dev/"
1112
}
1213
],
1314
"require": {
@@ -16,16 +17,12 @@
1617
"php-http/client-common": "^2.7",
1718
"php-http/discovery": "^1.18",
1819
"php-http/logger-plugin": "^1.3",
19-
"psr/cache": "^3.0",
20+
"psr/cache": "^2.0 || ^3.0",
2021
"psr/http-client": "^1.0",
2122
"psr/http-factory": "^1.0",
22-
"psr/log": "^3.0",
23+
"psr/log": "^2.0 || ^3.0",
2324
"symfony/options-resolver": "^6.3"
2425
},
25-
"provide": {
26-
"psr/http-client-implementation": "^1.0",
27-
"psr/http-factory-implementation": "^1.0"
28-
},
2926
"require-dev": {
3027
"monolog/monolog": "^3.4",
3128
"nyholm/psr7": "^1.8",
@@ -35,6 +32,10 @@
3532
"symfony/http-client": "^6.3",
3633
"symfony/var-dumper": "^6.3"
3734
},
35+
"provide": {
36+
"psr/http-client-implementation": "1.0",
37+
"psr/http-factory-implementation": "1.0"
38+
},
3839
"autoload": {
3940
"psr-4": {
4041
"ProgrammatorDev\\OpenWeatherMap\\": "src/"

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)