{"id":20215328,"url":"https://github.com/scrnr/openweatherapi-php","last_synced_at":"2025-10-11T15:41:43.142Z","repository":{"id":153959729,"uuid":"630580912","full_name":"scrnr/OpenWeatherApi-PHP","owner":"scrnr","description":"OpenWeatherApi application in PHP","archived":false,"fork":false,"pushed_at":"2023-04-28T11:30:44.000Z","size":8,"stargazers_count":1,"open_issues_count":0,"forks_count":2,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-09-20T22:26:33.525Z","etag":null,"topics":["open-weather-api","php","weather"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/scrnr.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2023-04-20T17:28:35.000Z","updated_at":"2023-05-29T12:00:36.000Z","dependencies_parsed_at":"2023-12-30T00:23:33.334Z","dependency_job_id":"80cf0bd2-7b30-4241-b945-a7d2998315b2","html_url":"https://github.com/scrnr/OpenWeatherApi-PHP","commit_stats":{"total_commits":7,"total_committers":1,"mean_commits":7.0,"dds":0.0,"last_synced_commit":"d739a97b4d5bb54b31fde2d6ad20b487d8e92735"},"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/scrnr/OpenWeatherApi-PHP","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/scrnr%2FOpenWeatherApi-PHP","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/scrnr%2FOpenWeatherApi-PHP/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/scrnr%2FOpenWeatherApi-PHP/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/scrnr%2FOpenWeatherApi-PHP/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/scrnr","download_url":"https://codeload.github.com/scrnr/OpenWeatherApi-PHP/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/scrnr%2FOpenWeatherApi-PHP/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279007601,"owners_count":26084334,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-10-11T02:00:06.511Z","response_time":55,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["open-weather-api","php","weather"],"created_at":"2024-11-14T06:21:23.955Z","updated_at":"2025-10-11T15:41:43.101Z","avatar_url":"https://github.com/scrnr.png","language":"PHP","readme":"# OpenWeatherMap API Application in PHP\n\n\u003cdiv\u003e\n    \u003cimg src='https://img.shields.io/packagist/dependency-v/scrnr/weather/php?label=PHP\u0026logo=php\u0026style=plastic\u0026color=orange' alt='PHP Version'\u003e\n    \u003cimg src='https://img.shields.io/packagist/v/scrnr/weather?label=Packagist\u0026logo=packagist\u0026logoColor=white\u0026style=plastic' alt='Packagist Version'\u003e\n    \u003cimg src='https://img.shields.io/packagist/l/scrnr/weather?label=LICENSE\u0026style=plastic' alt='LICENSE'\u003e\n\u003c/div\u003e\n\n\u003cbr\u003e\n\n## Table Of Contects\n\n* [Description](#description)\n* [Installation](#installation)\n* [How to use](#how-to-use)\n* [Example](#for-example)\n* [Features](#features)\n* [Requirements](#requirements)\n* [Author](#author)\n* [License](#license)\n\n## Description\n\nThis repository written in PHP that allows you to check the weather for a particular location using the OpenWeatherMap API 2.5. The app can determine your location by IP address and show the weather information or you can enter the name of any city.\n\n## Installation\n\nYou can install the library using [Composer](https://getcomposer.org/). Simply add the following lines to your `composer.json` file and run `composer install`:\n\n```json\n\"require\": {\n    \"scrnr/weather\": \"*\"\n}\n```\n\nOr you can use this **command**:\n\n```bash\ncomposer require scrnr/weather\n```\n\n## How to use\n\nTo use this app, you'll need to obtain an **API key** from the [OpenWeatherMap website](https://openweathermap.org/api) and set it using the `setToken()` function. The `setToken()` function accepts a token in string format.\n\nOnce you've set your **API key**, you can retrieve weather data using the `getWeather()` function. This function accepts two parameters: `CITY_NAME` and `UNITS_OF_MEASUREMENT`.\n\n* `CITY_NAME` accepts the name of the city in string format\n* `UNITS_OF_MEASUREMENT` accepts either `Units::METRIC` or `Units::IMPERIAL` as constants to specify the units of measurement.\n\nIf you do not set these parameters, the function will automatically determine the city based on the *IP address* and use the *metric system* as the *default* units of measurement.\n\nIf the `getWeather()` function returns false, you can use the `getErrors()` function to retrieve information about the error. This will allow you to troubleshoot any issues that may have occurred during the process.\n\nThank you for using my OpenWeatherMap API Application!\n\n## For example:\n\n```php\nuse Scrnr\\Weather\\Weather;\n\nWeather::setToken('YOUR_TOKEN');\n$forecast = Weather::getWeather('CITY_NAME', 'UNITS');\n\nif ($forecast === false) {\n    $errors = Weather::getErrors();\n}\n```\n\n### Output\n\n```php\nArray\n(\n    [today] =\u003e Array\n        (\n            [sunrise] =\u003e 05:09\n            [sunset] =\u003e 20:43\n            [date] =\u003e 27 April\n            [description] =\u003e Overcast clouds\n            [temp] =\u003e 5\n            [feelsLike] =\u003e 1\n            [pressure] =\u003e 755 mm Hg\n            [humidity] =\u003e 90%\n            [cityName] =\u003e Saint Petersburg\n            [visibility] =\u003e more than 10 km\n            [wind] =\u003e Array\n                (\n                    [speed] =\u003e 7 m/s\n                    [direction] =\u003e East\n                )\n\n            [isNight] =\u003e false\n            [icon] =\u003e http://openweathermap.org/img/wn/04d@2x.png\n            [tempMin] =\u003e 4\n        )\n        \n    [fourDays] =\u003e Array\n        (\n            [0] =\u003e Array\n                (\n                    [date] =\u003e 28 April\n                    [icon] =\u003e http://openweathermap.org/img/wn/04d@2x.png\n                    [max] =\u003e 7\n                    [min] =\u003e 3\n                )\n\n            [1] =\u003e Array\n                (\n                    [date] =\u003e 29 April\n                    [icon] =\u003e http://openweathermap.org/img/wn/10d@2x.png\n                    [max] =\u003e 4\n                    [min] =\u003e 4\n                )\n\n            [2] =\u003e Array\n                (\n                    [date] =\u003e 30 April\n                    [icon] =\u003e http://openweathermap.org/img/wn/10d@2x.png\n                    [max] =\u003e 7\n                    [min] =\u003e 4\n                )\n\n            [3] =\u003e Array\n                (\n                    [date] =\u003e 01 May\n                    [icon] =\u003e http://openweathermap.org/img/wn/10d@2x.png\n                    [max] =\u003e 7\n                    [min] =\u003e 2\n                )\n        )\n)\n```\n\n## Features\n\nThis app offers the following features:\n\n* Ability to check weather for a specific city\n* Automatic location detection using IP address\n* Display of current weather conditions, temperature, humidity, and wind speed\n* Display of a 4-day weather forecast\n\n## Requirements\n\nThis app requires `PHP 8.0` or later and the `cURL` and `json` extensions to be installed on your web server.\n\n## Author\n👤 GitHub: [scrnr](https://github.com/scrnr)\n\n## License\n\nThis project is licensed under the MIT License. See the [LICENSE](https://github.com/scrnr/OpenWeatherApi-PHP/blob/main/LICENSE) file for details.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fscrnr%2Fopenweatherapi-php","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fscrnr%2Fopenweatherapi-php","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fscrnr%2Fopenweatherapi-php/lists"}