Laravel API Boilerplate using Laravel Passport
Laravel API Boilerplate is a starting point for your first API.
It is built on top of:
- Laravel Framework - laravel/laravel
- Laravel Passport - laravel/passport
- Laravel-CORS barryvdh/laravel-cors
composer create-project usamamuneerchaudhary/laravel-api-boilerplate myfirstApi;
Generate Passport encryption keys & secret access tokens
php artisan passport:install
Generate application key by
php artisan key:generate
After DB Connection, run
php artisan migrate. For dummy data for users, run
php artisan migrate --seed. You can see more info in
For Testing Emails, you can setup MailTrap.
Well that's it lad, it would be up and running on your server already.
Basic Requirements for the Project
Ready-To-Use Authentication Controllers
You can find Authentication Controllers under namespace
There are also the validation rules for every action (login, sign up, recovery and reset) under namespace
- Find Reset Token
- Verify Email
Please note that, api routes are prefixed with
v1, you can changed this in
Separate File for Routes
All the API routes can be found in the
We're using akaunting/firewall to secure our API.
Roles & Permissions
Simpler way of assigning Roles & Permissions to Users. You can more details on what we've done here on usamamuneerchaudhary/roles-permissions
You can create your endpoints in
auth:api middleware group.
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.
This project is open-sourced software licensed under the MIT license.