This is an example of a REST API using auth tokens with Laravel Sanctum
-
Create a database.sqlite file in the database directory
-
Add the database info in the .env file:
For SQLite, add
DB_CONNECTION=sqlite DB_HOST=127.0.0.1 DB_PORT=3306
-
Run the web server on port 8000:
php artisan serve
-
Public
GET /api/products @desc: Get all the products GET /api/products/:id @desc: Get a sigle product POST /api/login @body: email, password @desc: User login POST /api/register @body: name, email, password, password_confirmation @desc: User registration
-
Protected
POST /api/products @body: name, slug, description, price @desc: Add a product PUT /api/products/:id @body: ?name, ?slug, ?description, ?price @desc: Update a product DELETE /api/products/:id @desc: Delete a product POST /api/logout @desc: User logout