A boot camp who initialize a series of tools for starter of laravel 5.5
-
Installation:
- Run command:
composer require jetwaves/laravel-bootcamp
- Edit config/app.php, add following line into 'providers' array
Jetwaves\LaravelBootcamp\Providers\LaravelBootcampServiceProvider::class,
- Edit '.env', set your database options (database name, username, password)
-
Jwt (Json Web Token ) Integration.
-
Initialisation
Run command in console:
php php artisan bootcamp:init
-
Test it's working:
- Run
php artisan serve
in cli. - Import "Tests/postman/Laravel_Jwt_integration_Test.postman_collection.json" into Postman
- Run the tests 1-9. You should see following results:
- test1:
it works !!!
- test2:
"error": "Token is required"
- test3:
The name field is required.,The email field is required.,The password field is required.
- test4:
{ "status": true, "message": "JwtUser created successfully", "data": { "name": "test1", "email": "[email protected]", "updated_at": "2018-02-17 12:12:36", "created_at": "2018-02-17 12:12:36", "id": 2 } }
- test5:
The email field is required.,The password field is required.
- test6:
"invalid_email_or_password"
- test7:
"token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.***********************"
- test8: (change the 'Authorization' field of the header with 'Bearer '.$tokenReturnedInTest7 )
it works !!!
- test9: (change the 'Authorization' field of the header with 'Bearer '.$tokenReturnedInTest7 )
"result": { "id": 1, "name": "test1", "email": "[email protected]", "created_at": "2018-02-17 11:57:01", "updated_at": "2018-02-17 11:57:01" }
- test1:
- Run
-
Usage:
A simple implicit router protected with jwt is declared in routes/api.php
Routes without jwt protection:
GET http://localhost:8000/api/noauth/ControllerName/snake-form-function-name is served by ControllerNameController->getSnakeFormFunctionName() POST http://localhost:8000/api/noauth/ControllerName/snake-form-function-name is served by ControllerNameController->postSnakeFormFunctionName()
Routes with jwt protection:
GET http://localhost:8000/api/withauth/ControllerName/snake-form-function-name is served by ControllerNameController->getSnakeFormFunctionName() POST http://localhost:8000/api/withauth/ControllerName/snake-form-function-name is served by ControllerNameController->postSnakeFormFunctionName()
Cf. Jetwaves/ Laravel Implicit Router to know more about implicit router for laravel 5.2+
-
Errors and eventual problems:
- To be completed later.
-