jetwaves/laravel-bootcamp

A boot camp who initialize a series of tools for starter of laravel 5.5

v1.0.1 2018-02-17 11:45 UTC

This package is not auto-updated.

Last update: 2024-03-25 05:01:42 UTC


README

A boot camp who initialize a series of tools for starter of laravel 5.5

  1. 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)
  2. Jwt (Json Web Token ) Integration.

    1. Initialisation

      Run command in console: php php artisan bootcamp:init

    2. 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:
        1. test1:
          it works !!! 
        2. test2:
          "error": "Token is required"
        3. test3:
          The name field is required.,The email field is required.,The password field is required.
        4. test4:
          {
              "status": true,
              "message": "JwtUser created successfully",
              "data": {
                  "name": "test1",
                  "email": "test@test.com1",
                  "updated_at": "2018-02-17 12:12:36",
                  "created_at": "2018-02-17 12:12:36",
                  "id": 2
              }
          }
        5. test5:
          The email field is required.,The password field is required.
        6. test6:
          "invalid_email_or_password"
        7. test7:
          "token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.***********************"
        8. test8: (change the 'Authorization' field of the header with 'Bearer '.$tokenReturnedInTest7 )
          it works !!! 
        9. test9: (change the 'Authorization' field of the header with 'Bearer '.$tokenReturnedInTest7 )
          "result": {
                  "id": 1,
                  "name": "test1",
                  "email": "test@test.com1",
                  "created_at": "2018-02-17 11:57:01",
                  "updated_at": "2018-02-17 11:57:01"
              }
    3. 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+

    4. Errors and eventual problems:

      1. To be completed later.