Laravel API Setup


Introduction

JSON:API is a specification for how a client should request that resources be fetched or modified, and how a server should respond to those requests. It is designed to minimize both the number of requests and the amount of data transmitted between clients and servers. This efficiency is achieved without compromising readability, flexibility, or discoverability.


Click here to go to the JSON:API docs

Prerequisites API

The Laravel JSON:API backend project requires a working Apache/Nginx local environment with PHP, Composer and MySQL.

If you don't already have a local development environment, use one of the following links:

Laravel API Project Installation

  • Navigate in your Laravel API project folder: cd your-laravel-json-api-project
  • Install project dependencies: composer install
  • Create a new .env file: cp .env.example .env
  • Add your own database credentials in the .env file in DB_DATABASE, DB_USERNAME, DB_PASSWORD
  • Create users table: php artisan migrate --seed
  • Generate application key: php artisan key:generate
  • Install Laravel Passport: php artisan passport:install and set in the .env file the CLIENT_ID and CLIENT_SECRET that you receive
  • Add your own mailtrap.io credentials in MAIL_USERNAME and MAIL_PASSWORD in the .env file