diego-rlima / simple-news-api

Simple RESTful API for managing news.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Laravel Simple News Api

This repository is part of an interview test. You can check the requirements here (pt-BR).

It's based on my starter kit for developing RESTful APIs with Laravel and Docker. This ships with PHP 7.3-fpm, Nginx 1.15.8-alpine and MySQL 5.7.25.

Requirements

You only need Docker and Docker Compose installed.

Getting Started

First, clone this repository or just download it.

$ git clone https://github.com/diego-rlima/simple-news-api.git

After, install the Laravel dependencies with Composer.

$ cd ./simple-news-api
$ docker run --rm -v $(pwd):/app composer install

Set the permissions on the project folder.

$ sudo chown -R $USER:$USER /path/to/simple-news-api

Create the .env file.

$ cp .env.example .env

Edit the .env file end put the default admin user info.

$ nano .env

DEFAULT_ADMIN_NAME=
DEFAULT_ADMIN_EMAIL=
DEFAULT_ADMIN_PASSWORD=

Finally, inside the project folder, just run:

$ docker-compose up -d

You can check if the containers are running

$ docker ps

If is everything ok, it will output something like:

CONTAINER ID        IMAGE               COMMAND                  CREATED             STATUS              PORTS                                         NAMES
de320d716e6c        mysql:5.7.25        "docker-entrypoint.s…"   2 minutes ago   2 minutes ago    33060/tcp, 0.0.0.0:3360->3306/tcp             mysql_service
a53498ca08b6        diegoribeiro/php    "docker-php-entrypoi…"   2 minutes ago   2 minutes ago    9000/tcp                                      app
c3fafc29c50f        nginx:alpine        "nginx -g 'daemon of…"   2 minutes ago   2 minutes ago    0.0.0.0:8000->80/tcp, 0.0.0.0:8443->443/tcp   nginx_service

Next, set the the APP_KEY and the JWT_SECRET for the Laravel application.

$ docker-compose exec app php artisan key:generate
$ docker-compose exec app php artisan jwt:secret

Run the migrations.

$ docker-compose exec app php artisan migrator

Note: For this, the Migrator package is used instead of the standard migrations.

Accessing the Application

You can access the application by typing the address http://localhost:8000.

The database can be accessed by using the host localhost and the port 3360. The default database name, user, and password are, respectively, laravel, root and secret.

License

Like Laravel, this repository is licensed under the MIT license.

About

Simple RESTful API for managing news.


Languages

Language:PHP 97.2%Language:HTML 2.1%Language:Dockerfile 0.5%Language:Vue 0.2%