run following commands:
composer install
php artisan migrate
php artisan app:initial-app
php artisan app:fetch-news
( for test on local server)
- there is a laravel schedule task that can be used for production server.
it runs every hour and fetches news.
use this cron entry:
* * * * * cd /path-to-your-project && php artisan schedule:run >> /dev/null 2>&1
php artisan php artisan queue:work
(I added them to .env.example for easy setup)
NEWS_SOURCE_NYT_API_KEY=5bD4StZTmIKQnsNDKJmoDJcyh4txSA6b NEWS_SOURCE_THEGUARDIAN_API_KEY=67bac5a6-6d7b-4165-9b3e-209fad49167b NEWS_SOURCE_NEWSAPIORG_API_KEY=11030aee1ac1490ca379d95e167c0a9b
NEWS_SOURCE_NYT_URL=https://api.nytimes.com/svc/news/v3/content/all/all.json NEWS_SOURCE_THEGUARDIAN_URL=https://content.guardianapis.com/search NEWS_SOURCE_NEWSAPIORG_URL=https://newsapi.org/v2/top-headlines
NEWS_SOURCE_NYT_SECTIONS_URL=https://api.nytimes.com/svc/news/v3/content/section-list.json NEWS_SOURCE_THEGUARDIAN_SECTIONS_URL=https://content.guardianapis.com/sections
- Preventing of saving repetitive articles
- Tests
- Dockerizing
- newsapi.org
- The guardian
- New York Times
for every news source each one puts ProcessArticleFetch jobs to fetch the content then the result will be added to queue to be processed by ProcessArticle job.