jafar690 / laravel-api-jwt-starter by jafar690

Laravel API boilerplate with jwt authentication
5
2
1
Package Data
Maintainer Username: jafar690
Package Create Date: 2017-07-04
Package Last Update: 2017-07-09
Language: PHP
License: MIT
Last Refreshed: 2024-04-18 15:10:58
Package Statistics
Total Downloads: 5
Monthly Downloads: 0
Daily Downloads: 0
Total Stars: 2
Total Watchers: 1
Total Forks: 0
Total Open Issues: 0

Laravel API JWT Starter

Laravel API JWT Starter is a "starter kit" you can use to build your first API in seconds. It is based on larave 5.4!

It is built on top of three packages:

What I made is an integration of these three packages and a setup of some authentication and credentials recovery methods.

Installation

  1. run composer create-project jafar690/laravel-api-jwt-starter yourProjectName;
  2. have a coffee, nothing to do here;

Once the project creation procedure will be completed, run the php artisan migrate command to install the required tables.

Main Features

Ready-To-Use Authentication Controllers

You don't have to worry about authentication and password recovery anymore. I created four controllers you can find in the App\Http\Controllers\Auth\ for those operations.

For each controller there's an already setup route in routes/api.php file:

  • POST api/auth/login, to do the login and get your access token;
  • POST api/auth/register, to create a new user into your application;
  • POST api/auth/recovery, to recover your credentials;
  • POST api/auth/reset, to reset your password after the recovery;

A Separate File for Routes

All the API routes can be found in the routes/api.php file. This also follow the Laravel 5.3 convention.

On create project commands

Every time you create a new project starting from this repository,the php artisan jwt:generate command will be executed.

Configuration

This boilerplate is based on dingo/api and tymondesigns/jwt-auth packages. So, you can find many informations about configuration here and here.

I have made some minor changes to the DINGO API configuration file in config/api.php

  • sign_up.release_token: set it to true if you want your app release the token right after the sign up process;
  • reset_password.release_token: set it to true if you want your app release the token right after the password reset process;

I have also created form requests for every action (login, register, recovery and reset). Feel free to customize it for your needs.

Creating Endpoints

You can create endpoints in the same way you could to with using the single dingo/api package. You can read its documentation for details. After all, that's just a boilerplate! :)

However, I added some example routes to the routes/api.php file to give you immediately an idea.

Cross Origin Resource Sharing

If you want to enable CORS for a specific route or routes group, you just have to use the cors middleware on them.

Thanks to the barryvdh/laravel-cors package, you can handle CORS easily. Just check the docs at this page for more info.

Feedback

For any questions or feedback, feel free to send me an email at kgakami690@gmail.com