A dynamic weather application that displays real-time temperature, humidity, and weather conditions. Changes background effects based on weather (rain, sun, clouds) and time of day (day/night). Built with PHP (OOP) and OpenWeatherMap API.
## Features
- 🌞 Day/Night mode (auto-detected via sunrise/sunset times)
- 🌧️ Dynamic weather effects (rain, clear sky, clouds)
- 📱 Responsive design
- 🔍 Error handling for invalid locations
## Technologies
- PHP 7.4+ (OOP)
- HTML/CSS
- OpenWeatherMap API
## Setup
### 1. Clone the Repository
```bash
git clone https://github.com/yourusername/weather-app.git
cd weather-app- Get API Key: Sign up at OpenWeatherMap (free tier).
- Rename Config File:
mv config-example.php config.php
- Add Key: Open
config.phpand replaceyour_api_key_herewith your actual key:define('API_KEY', 'your_api_key_here');
- Place the project in your web server (e.g., XAMPP
htdocs). - Start Apache/PHP server.
- Visit:
http://localhost/weather-app
Create/download these files (or modify code to match your filenames):
rain-day.gif,rain-night.gifsunny.jpg,night.jpgcloudy-day.jpg,cloudy-night.jpg
weather-app/
├── index.php
├── Weather.php
├── config.php
├── config-example.php
├── styles.css
├── README.md
└── (media files)
- Enter a city/country (e.g., "Tokyo" or "Egypt").
- Click "Get Weather".
- See temperature, humidity, and dynamic background!
Weather in Egypt
Temperature: 22 °C
Humidity: 65%
Condition: Clear (Night Theme)
- 401 Error: Invalid API key → Recheck
config.php. - City Not Found: Ensure spelling (e.g., "New York" not "NewYork").
- Missing Backgrounds: Add images/GIFs or update CSS in
Weather.php.
- Fork the repository.
- Create a branch:
git checkout -b feature/new-feature. - Commit changes:
git commit -m 'Add feature'. - Push:
git push origin feature/new-feature. - Open a pull request.
MIT License. See LICENSE.