Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/moemoe89/laravel-book

📚 Fun REST API project with PHP (Laravel) as Backend, VueJS as Frontend, Cypress as E2E Testing, Docker as Container, Swagger as API Documentation
https://github.com/moemoe89/laravel-book

bitbucket-pipelines cypress docker e2e-testing heroku laravel php swagger vuejs

Last synced: about 15 hours ago
JSON representation

📚 Fun REST API project with PHP (Laravel) as Backend, VueJS as Frontend, Cypress as E2E Testing, Docker as Container, Swagger as API Documentation

Awesome Lists containing this project

README

        

# Book Management

Book Management is a simple web application for manage book with the author.

- Managing Author data
- Managing Book data
- Export Data to CSV & XML

### Tech Stack

Book management uses a number of open source projects to work properly:

* [Laravel](https://laravel.com) - Backend Rest API
* [Composer](https://getcomposer.org/) - Tool dependency management in PHP
* [PostgreSQL](https://www.postgresql.org) - Database
* [Node.js](https://nodejs.org/en) - JavaScript runtime environment
* [NPM](https://www.npmjs.com/) - Package manager for the JavaScript
* [VueJS](https://vuejs.org) - Frontend Web
* [Cypress](https://www.cypress.io) - E2E Testing API & Web
* [Swagger](https://swagger.io) - API Documentation
* [Docker](https://www.docker.com) - App Container
* [Bitbucket Pipelines](https://bitbucket.org/product/features/pipelines) - Pipeline Deployment
* [Heroku](https://heroku.com) - Cloud Application Platform

### Requirements

Book management is currently extended with the following requirements. Instructions on how to use them in your own application are linked below.

| Requirement | Version |
| ------ | ------ |
| PHP | >= 7.2.0 |
| PosgtreSQL | >= 12.0 |
| NodeJS | >= 12.9.0 |
| NPM | >= 6.13.0 |
| Docker | >= 19.03.0 |

### Installation

Make sure you the requirements above already install on your system. Or you could easily run with Docker to make your environment clean.

Clone the project to your directory and install the dependencies.

```sh
$ git clone [email protected]:momo89/book.git
$ cd book
$ composer install
$ npm install
```

Setup your environments.

```sh
$ cp .env.example .env
$ php artisan key:generate
```
Change your PostgreSQL credentials depends on your PostgreSQL installed config.
```sh
DB_CONNECTION=pgsql
DB_HOST=127.0.0.1
DB_PORT=5432
DB_DATABASE=book
DB_USERNAME=postgres
DB_PASSWORD=
```

### Migrate

Setup your migration following by this command.

```sh
$ php artisan migrate
```

#### Run Application
For run application:
```sh
$ npm run dev
$ php artisan serve
```

Easily command with make:
```sh
$ make run
```

Verify the apllication by navigating to your server address in your preferred browser.

```sh
127.0.0.1:8000
```

### Docker
Book management is very easy to install and deploy in a Docker container. Simply use the docker-compose build to build the image.

```sh
$ docker-compose build
```
Once done, run the Docker image by using docker-compose up command.

```sh
$ docker-compose up -d
```

Setup the DB migration by using docker-compose exec command.
```sh
$ docker-compose exec app php artisan migrate
```

Verify the application by navigating to your server address in your preferred browser.

```sh
127.0.0.1:8000
```

Stop application could be done with docker-compose stop command.
```sh
$ docker-compose stop
```

### Swagger

Book management has Rest API Documentation generated by Swagger for understanding how's API work and/or want to extend to another platform.

See the documentation by navigating to your server address in your preferred browser.

```sh
127.0.0.1:8000/api/documentation
```

Generating the documentation if there's any changes on Swagger Annotation.
```sh
$ php artisan l5-swagger:generate
```
### Integration Testing

Book management has Integration Testing using PHPUnit & sqlite for testing both the API
Run this command for running the test:
```sh
$ vendor/phpunit/phpunit/phpunit
```

If running using docker:
```sh
docker-compose exec app vendor/phpunit/phpunit/phpunit
```

### E2E Testing

Book management has E2E Testing using Cypress for testing both the API & Web.

```sh
$ npm install
$ npx cypress open
```

Easily command with make:
```sh
$ make e2e
```

By default Cypress will be opened the GUI for run the test cases.
The URL for Cypress do E2E testing configured on `tests/E2E/cypress/support/constant.js`.
For changing the URL, easily to change the value from URL Constants.
```sh
const Constants = {
URL: 'http://127.0.0.1:8000'
}
export default Constants
```

### Heroku

Book management supported for Heroku deployment using Bitbucket pipelines.
If you want to deploy automatically to Heroku from Bitbucket, changes the `HEROKU_API_KEY` & `HEROKU_APP_NAME` on your Bitbucket repository variables for auto deployment to your Heroku App.

Setup the environment variables on Heroku setting page.
```sh
APP_KEY
DB_CONNECTION
DB_HOST
DB_PORT
DB_DATABASE
DB_USERNAME
DB_PASSWORD
```

Setup the DB migration by using heroku command.
```sh
$ heroku run php artisan migrate --app {{heroku-app-name}}
```

Available demo can find on this Heroku App

```sh
https://momo-book.herokuapp.com
```

### Todos

- Write Unit Test
- Support E2E Test on Docker

License
----

MIT