jetwaves/laravel-bootcamp

一个为 Laravel 5.5 入门者初始化一系列工具的训练营

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

This package is not auto-updated.

Last update: 2024-09-23 07:19:55 UTC


README

一个为 Laravel 5.5 入门者初始化一系列工具的训练营

  1. 安装

    • 运行命令
    composer require jetwaves/laravel-bootcamp
    • 编辑 config/app.php 文件,将以下行添加到 'providers' 数组中
    Jetwaves\LaravelBootcamp\Providers\LaravelBootcampServiceProvider::class,
    • 编辑 '.env' 文件,设置您的数据库选项(数据库名称、用户名、密码)
  2. Jwt (Json Web Token ) 集成。

    1. 初始化

      在控制台中运行命令:php php artisan bootcamp:init

    2. 测试其是否正常工作

      • 在 cli 中运行 php artisan serve
      • 将 "Tests/postman/Laravel_Jwt_integration_Test.postman_collection.json" 导入 Postman
      • 运行测试 1-9。您应该看到以下结果
        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: (将头部中的 'Authorization' 字段更改为 'Bearer '.$tokenReturnedInTest7 )
          it works !!! 
        9. test9: (将头部中的 'Authorization' 字段更改为 '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. 用法

      在 routes/api.php 中声明了一个简单的隐式路由保护 jwt

      无 jwt 保护的路由

       GET https://:8000/api/noauth/ControllerName/snake-form-function-name is served by ControllerNameController->getSnakeFormFunctionName()
       POST https://:8000/api/noauth/ControllerName/snake-form-function-name is served by ControllerNameController->postSnakeFormFunctionName()
      

      有 jwt 保护的路由

       GET https://:8000/api/withauth/ControllerName/snake-form-function-name is served by ControllerNameController->getSnakeFormFunctionName()
       POST https://:8000/api/withauth/ControllerName/snake-form-function-name is served by ControllerNameController->postSnakeFormFunctionName()                
      

      有关 Laravel 5.2+ 的隐式路由的更多信息,请参阅 Jetwaves/ Laravel Implicit Router

    4. 错误和可能出现的问题

      1. 稍后完成。