Laravel API with Passport Token Authentication

This is the fastest way to deploy a laravel API app with passport and token.

Tihs was tested from an Ubuntu 20.04TLS virtual Machine with Windows 10 Host as of February 15, 2021.

Requirements:

  • Composer
  • Git
  • Docker
  • docker-compose
  • curl
  • bash
  • ubuntu linux

Ok, here is the command and the instruction. Very simple:

First Command:

bash <(curl -s  https://www.webune.com/forums/web/img/webune-com/202102/15-p4925-api.txt)
  1. On the first question, leave it blank for the default github repository
  2. Enter the app name: example: api28
  3. You will be asked to enter a mysql command to create a database in the mysql container: the command will look like the one below:
    # mysql --password= --execute="create database"
  4. After the scripts completed, you can start testing your API

API TESTING:

You can use your favorite API Development application like Postman or Imsomnia for example

1. Creat User
POST: http://localhost/api/register
email: [email protected]
password: example123

2. Login user
POST: http://localhost/api/login
email: [email protected]
password: example123
NOTE: TOKEN

3. Create CEO
POST: http://localhost/api/ceo
name: Steve Jobs
year: 2021
company_headquarters: cupertino
what_company_does: phones
company_name: apple
Provide TOKEN from step 2

Other endpoints:

  • Get list of CEOs: GET: http://localhost/api/ceo
  • Get CEO Details: GET: http://localhost/api/ceo/1
  • Update CEO Details: PATCH: http://localhost/api/ceo/1
  • Delete CEO: DELETE: http://localhost/api/ceo/1

For more details you go visit the repository:

https://github.com/edwinaquino/laravel-backend-api