It's a web that uses NewsAPI like main API to get differents news about something particular or some topic like health. This app provides two types of search, the first one it's about searching some concret thing, the other gets latest news.
The goal was to dive into concepts like Service Provider and Service Container, also other of the purposes was to enhance SOLID principles like Interface Segretation Principle (IS) and Dependency Inversion Principle (DIP).
It's not like other applications that have a strong dependency with a specific API, this app offers to the users the ability to change over API news with a few modifications, thanks to Interface Segregation Principle
It's easy, just :
- Laravel 8 with the last available version at the moment Laravel .
- Laravel Breeze for handle authentication features, Laravel Breeze .
- But also MySQL and SQLite.
Some pictures about the app :
Clone the repository and install project dependencies with :
git clone git@github.com:joslmt/news-api.git
composer install
It's necessary gets a .env
file, so writte in console :
cp .env.example .env
Now, generate an own key for your project :
php artisan key:generate
Finally, push your database config within .env
.
DB_CONNECTION=mysql
DB_HOST=
DB_PORT=3306
DB_DATABASE=
DB_USERNAME=
DB_PASSWORD=
Just go to NewsAPI and click 'Get API Key' .
There're some options, if you use something like XAMPP or similar :
php artisan serve
Or a good alternative like Docker or Homestead like me, take a look to one of my previous projects where I explained the steps to get Homestead installed. How to install Homestead for Laravel.
To test the app I decided to use SQLite, just for speed. It's required to get a new .env
where config the database options to SQLite and also create a SQLite database.
touch database/database.sqlite
cp .env.example .env.testing
Then, within .env.testing
replace database variables with :
DB_CONNECTION=sqlite
DB_DATABASE=/absolute/path/to/database.sqlite
Finally :
php artisan test --env=testing
And don't forget to put your API key.