A PHP-based Weather API that fetches and returns weather data from Visual Crossing's API uses predis for Redis cache and phpdotenv for loads environment variables. This project inspired by roadmap.sh.
To start using the Expense Tracker API, you need to -
-
Clone the repository.
git clone https://github.com/krisnaajiep/php-weather-api.git
-
Install dependencies.
composer install
-
Configure
.env
file.cp .env.example .env
-
Configure API key and Redis connection in
.env
file.API_BASE_URL="https://weather.visualcrossing.com/VisualCrossingWebServices/rest/services/timeline/" API_KEY="" REDIS_HOST=127.0.0.1 REDIS_PASSWORD=null REDIS_PORT=6379 REDIS_CACHE_DB=0
-
Run the PHP built-in server.
php -S localhost:8000
-
Access the endpoint with location query parameter.
Example:
http://localhost:8000/?location=jakarta
In case you have questions or need further assistance, you can refer to the following resources: