Home
Softono
laravel-books-api

laravel-books-api

Open source MIT PHP
68
Stars
10
Forks
9
Issues
2
Watchers
3 years
Last Commit

About laravel-books-api

<h1 align="center"> Laravel Books API </h1> <p align="center"> <a href="https://github.com/yusuftaufiq/laravel-books-api/actions/workflows/test.yml"> <img alt="Tests Workflow Status" src="https://img.shields.io/github/actions/workflow/status/yusuftaufiq/laravel-books-api/test.yml?label=tests&logo=github&style=for-the-badge"> </a> <a href="https://github.com/yusuftaufiq/laravel-books-api/actions/workflows/lint.yml"> <img alt="Lint Codebase Workflow Status" src="https://img.shields.io/github/actions/workflow/status/yusuftaufiq/laravel-books-api/lint.yml?branch=main&label=lint&logo=github&style=for-the-badge"> </a> <a href="https://codecov.io/gh/yusuftaufiq/laravel-books-api"> <img alt="Code Coverage" src="https://img.shields.io/codecov/c/github/yusuftaufiq/laravel-books-api?logo=codecov&style=for-the-badge"> </a> <a href="https://github.com/yusuftaufiq/laravel-books-api/blob/main/LICENSE"> <img alt="License" src="https://img.shields.io/github/license/ ...

Platforms

Web Self-hosted Docker

Languages

PHP

Laravel Books API

Tests Workflow Status Lint Codebase Workflow Status Code Coverage License

Introduction

This app provides a list of books in a RESTful API. Source of data obtained from Gramedia by using the web scraping technique.

Purpose

Apart from providing a booklist API, this app was created primarily to learn how to write unit-testable code in Laravel and also presents use cases of framework features such as:

If you are interested in exploring this app, you can check to start from routes/api.php, app/ folder & tests/ folder.

Further reading

In addition to the official documentation from Laravel, here are some reference articles that help the development of this application and may be of interest to you:

API documentation

You can read the API documentation on the following page.

Installation

Manual installation

Requirements: PHP 8.1, Composer, RDBMS (such as: MySQL, SQLite, PostgreSQL, etc).

Installation steps:

  • Clone this repository git clone https://github.com/yusuftaufiq/laravel-books-api.git
  • Change directory cd laravel-books-api
  • Copy environment file cp .env.example .env
  • Set the database configuration you are using in .env
  • If you don't have SQLite installed, also set the database configuration in the file .env.testing
  • Make sure you have created the database according to the DB_DATABASE environment value you set
  • Install composer dependencies composer install
  • Run the migration using php artisan migrate
  • Run the application using php artisan serve

Via Docker

Requirements: Docker

Installation steps:

  • Clone this repository git clone https://github.com/yusuftaufiq/laravel-books-api.git
  • Change directory cd laravel-books-api
  • Copy environment file cp .env.example .env
  • You may want to change DOCKER_FORWARD_* in .env to prevent port conflicts
  • Build container with docker-compose up -d --build site
  • Install composer dependencies docker-compose run --rm composer install
  • Run the migration using docker-compose run --rm artisan migrate

Useful commands

  • composer cache:clear: clear app cache
  • composer code:analyze: run static code analyzer using PHP Stan and check code style using PHP Code Sniffer
  • php artisan insights: analyze code quality using PHP Insights
  • php artisan test: run feature & unit tests

Limitation

Since this app is currently hosted on Heroku using a free plan, there is no guarantee that this app will be accessible at any time.

Tech stack

Credits

License

This application is licensed under the MIT license.