Skip to content

RESTful api built using laravel with sanctum authentication.

Notifications You must be signed in to change notification settings

gcshisir/laravel-sanctum-rest

Repository files navigation

laravel-sanctum-rest

This is an example of a REST API using auth tokens with Laravel Sanctum

Usage

  • 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
    

Routes

  • 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
    

About

RESTful api built using laravel with sanctum authentication.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published