Laravel API Setup
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
The Laravel JSON:API 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:
- Windows: How to install WAMP on Windows
- Linux: How to install LAMP on Linux
- Mac: How to install MAMP on MAC
- Install Composer: https://getcomposer.org/doc/00-intro.md
Laravel API Project Installation
- Navigate in your Laravel API project folder:
cd your-laravel-json-api-project
- 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
- Add your own mailtrap.io credentials in MAIL_USERNAME and MAIL_PASSWORD in the .env file