News Aggregation API service built on Laravel
master
- Branch off it. Must be stable.dev
- For Development
Used for the API for News Aggregation, from NewsAPI, The Guardian & Newyork Times.
DB_DATABASE
- MySql DB Name. Defaults to laravel_new_apiDB_USERNAME
- MySql DB Username.DB_PASSWORD
- MySql DB Password
NEWSAPI_KEY_DISABLED
- The API key is given at NewsAPI.NEWSAPI_TIMEOUT
- Defaults to 15, if not set.NEWSAPI_RETRY_TIMES
- The number of times to retry fetching updated if failed on first request. Defaults to null, if not setNEWSAPI_RETRY_SLEEP
- The amount of time to wait between failed requests. Defaults to null, if not set
GUARDIANAPI_KEY
- The API key is given at The Guardian.GUARDIANAPI_TIMEOUT
- Defaults to 15, if not setGUARDIANAPI_RETRY_TIMES
- The number of times to retry fetching updated if failed on first request. Defaults to null, if not setGUARDIANAPI_RETRY_SLEEP
- The amount of time to wait between failed requests. Defaults to null, if not set
NEWYORKTIMESAPI_KEY
- The API key is given at The Newyork TimesNEWYORKTIMESAPI_TIMEOUT
- Defaults to 15, if not setNEWYORKTIMESAPI_RETRY_TIMES
- The amount of time to wait between failed requests. Defaults to null, if not setNEWYORKTIMESAPI_RETRY_SLEEP
- The amount of time to wait between failed requests. Defaults to null, if not set
A docker-based infrastructure is available for development. If you wish to run directly on host, see Setup below.
cp .env.example .env
- Set the database hostname in
.env
likeDB_HOST=laravel-news-db
docker compose --env-file .env -p laravel-news -f ./docker-compose.yml up -d
docker exec -it laravel-news-php php artisan key:generate
docker exec -it laravel-news-php php artisan migrate --seed
- Nginx listens at your local IP address, port 8082, e.g. http://localhost:8082
- Mysql container's port 3306 is mapped to the host.
- PHP8.2
- MySQL 8.0+
- Composer installed.
cp .env.example .env
- Popuplate Your
.env
file with the keys and databases specifics as specified in the configuration section. composer install
php artisan key:generate
php artisan migrate
php artisan serve
- When you visit
http://localhost:8082/api/news/top-headlines
if you used docker orhttp://localhost:8000/api/news/top-headlines
if you used local development, You should be able to see all the top-headlines
This Project is open sourced software licensed under the MIT license.