Download the PHP package scrnr/weather without Composer
On this page you can find all versions of the php package scrnr/weather. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download scrnr/weather
More information about scrnr/weather
Files in scrnr/weather
Package weather
Short Description OpenWeatherApi application in PHP
License MIT
Homepage https://github.com/scrnr/OpenWeatherApi-PHP
Informations about the package weather
OpenWeatherMap API Application in PHP
Table Of Contects
- Description
- Installation
- How to use
- Example
- Features
- Requirements
- Author
- License
Description
This 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.
Installation
You can install the library using Composer. Simply add the following lines to your composer.json
file and run composer install
:
Or you can use this command:
How to use
To use this app, you'll need to obtain an API key from the OpenWeatherMap website and set it using the setToken()
function. The setToken()
function accepts a token in string format.
Once 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
.
CITY_NAME
accepts the name of the city in string formatUNITS_OF_MEASUREMENT
accepts eitherUnits::METRIC
orUnits::IMPERIAL
as constants to specify the units of measurement.
If 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.
If 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.
Thank you for using my OpenWeatherMap API Application!
For example:
Output
Features
This app offers the following features:
- Ability to check weather for a specific city
- Automatic location detection using IP address
- Display of current weather conditions, temperature, humidity, and wind speed
- Display of a 4-day weather forecast
Requirements
This app requires PHP 8.0
or later and the cURL
and json
extensions to be installed on your web server.
Author
👤 GitHub: scrnr
License
This project is licensed under the MIT License. See the LICENSE file for details.
All versions of weather with dependencies
ext-curl Version *
ext-json Version *