GoravelGoravel
Home
Video
  • English
  • įŽ€äŊ“中文
GitHub
Home
Video
  • English
  • įŽ€äŊ“中文
GitHub
  • Prologue

    • Upgrade Guide

      • Upgrading To v1.15 From v1.14
      • Upgrading To v1.14 From v1.13
      • History Upgrade
    • Contribution Guide
    • Excellent Extend Packages
  • Getting Started

    • Installation
    • Configuration
    • Directory Structure
    • Compile
  • Architecture Concepts

    • Request Lifecycle
    • Service Container
    • Service Providers
    • Facades
  • The Basics

    • Routing
    • HTTP Middleware
    • Controllers
    • Requests
    • Responses
    • Views
    • Grpc
    • Session
    • Validation
    • Logging
  • Digging Deeper

    • Artisan Console
    • Cache
    • Events
    • File Storage
    • Mail
    • Queues
    • Task Scheduling
    • Localization
    • Package Development
    • Color
    • Strings
    • Helpers
  • Security

    • Authentication
    • Authorization
    • Encryption
    • Hashing
  • ORM

    • Getting Started
    • Relationships
    • Migrations
    • Seeding
    • Factories
  • Testing

    • Getting Started
    • HTTP Tests
    • Mock

Upgrading To v1.13 From v1.12

Exciting New Features 🎉

  • Seeding
  • Factories
  • Testing
  • Views

Enhancements 🚀

  • Upgrade The Default Version Of Golang To 1.20
  • Task Scheduling Supports Scale Horizontally
  • Add Debug Methods
  • make:controller Command Adds Parameter
  • Add Status Method For Response
  • Add Sum and Cursor Methods For Orm
  • The Route Module Supports Configure Driver
  • Add InputArray And InputMap Methods For Request
  • The Model Of Orm Supports Custom Connection
  • Add Cloudinary Driver For Filesystem
  • Add New Chain Methods For Log

v1.13.4

  • The Service Startup Supports Environment Variables

Breaking Changes 🛠

  • Remove The Global HTTP Middleware Loaded By Default
  • Optimize The Return of Controller
  • Change The Parameter Of The Group Method In facades.Route()
  • Optimize Remember And RememberForever Methods In facades.Cache()(If using)
  • Change The Package Name Of access.NewAllowResponse and access.NewDenyResponse(If using)
  • Remove Deprecated Methods(If using)

Bug Fixes 🐛

  • Fix facades.Auth().User()
  • Fix Custom .env Path Does Not Take Effect In Some Cases
  • Fix Token Expires Immediately When ttl == 0 Is Set In JWT

v1.13.2

  • Fix facades.Storage().Url() Returns Wrong Path Under Windows
  • Fix Abnormal Connection When The Postgres Password Is Empty
  • Fix The With Method Is Invalid When Using The Cursor Method Of Orm

v1.13.4

  • Fix The Validation Module Cant Verify The Route Params
  • Fix The Fiber Driver Cant Return File
  • Fix The Global Middleware Of Fiber Driver Panic
  • Fix The ContentType Setting of Fiber Driver Is Different From Gin Driver

v1.13.5

  • Fix The Connection Of Model Does Not Work
  • Fix The Error Of Mock Log

v1.13.6 v1.13.7

  • Fix The Problem Of Nonlinear Execution Of Query Chain

v1.13.8

  • Fix The Problem Of facades.Auth().Parse()
  • Fix The Problem of facades.Orm().WithContext()
  • The Queue Log Is Controlled By APP_DEBUG

v1.13.9

  • Fix The Problem Of The New Line Print Of Log Is Incorrect
  • Fix The Problem Of The vendor:publish Commabnd Can Not Publish Directory

v1.13.10

  • Fix The Traces Do Not Cleaned When Calling Log.Info After Log.Error
  • Fix The GetAttribute Of Orm Event Returns Error Data
  • Add ToSql, ToRawSql Methods For ORM

Upgrade Guide

Please upgrade the framework step by step according to the content in this section.

Estimated Upgrade Time: 10 Minutes

1. Updating Dependencies

Update dependencies in the go.mod file:

go get -u github.com/goravel/framework@v1.13.9 && go get -u github.com/goravel/gin

2. Add New Files

tests

database/seeders/database_seeder.go

app/providers/database_service_provider.go

3. Register New Providers

Note the order:

import (
  "github.com/goravel/framework/testing"
  "github.com/goravel/gin"
)

// config/app.go
"providers": []foundation.ServiceProvider{
  ...
  &validation.ServiceProvider{},
  // New
  &testing.ServiceProvider{}, 
  &providers.AppServiceProvider{},
  ...
  &providers.ValidationServiceProvider{},
  // New
  &providers.DatabaseServiceProvider{}, 
  // New
  &gin.ServiceProvider{}, 
}

4. Add Configuration

Modify config/http.go

import (
  "github.com/goravel/framework/contracts/route"
  "github.com/goravel/framework/facades"
  ginfacades "github.com/goravel/gin/facades"
)

config.Add("http", map[string]any{
  // HTTP Driver
  "default": "gin",
  // HTTP Drivers
  "drivers": map[string]any{
    "gin": map[string]any{
      "route": func() (route.Route, error) {
        return ginfacades.Route("gin"), nil
      },
    },
  },
  ...
}

Modify config/cors.go

config.Add("cors", map[string]any{
  ...
  // New
  "paths":                []string{"*"}, 
  "allowed_methods":      []string{"*"},
  ...
}

5. Remove The Global HTTP Middleware Loaded By Default

  1. The tls and cors middleware have been integrated into the default HTTP driver, therefore, middleware.Cors() and middleware.Tls() in the app/http/kernel.go file need to be removed.

  2. The facades.Route().GlobalMiddleware(http.Kernel{}.Middleware()...) method in the app/providers/route_service_provider.go file moves to Boot from Register:

package providers

...

type RouteServiceProvider struct {
}

func (receiver *RouteServiceProvider) Register(app foundation.Application) {
}

func (receiver *RouteServiceProvider) Boot(app foundation.Application) {
  //Add HTTP middleware
  facades.Route().GlobalMiddleware(http.Kernel{}.Middleware()...)

  receiver.configureRateLimiting()

  routes.Web()
}

func (receiver *RouteServiceProvider) configureRateLimiting() {

}

6. Optimize The Return of Controller

Controller adds return value http.Response, ctx.Response() can be return directly, there is no need to use return separately to make the logic smoother.

// Before
func (r *UserController) Show(ctx http.Context) {
  ctx.Response().Success().Json(http.Json{
    "Hello": "Goravel",
  })
  return
}

// After
func (r *UserController) Show(ctx http.Context) http.Response {
  return ctx.Response().Success().Json(http.Json{
    "Hello": "Goravel",
  })
}

7. Change The Parameter Of The Group Method In facades.Route()

Change route.Route to route.Routerīŧš

// Before
facades.Route().Group(func(route route.Route)

// After
facades.Route().Group(func(route route.Router)

8. Optimize Remember And RememberForever Methods In facades.Cache()(If using)

The type of callback changes to func() (any, error) from func() any:

// Before
Remember(key string, ttl time.Duration, callback func() any) (any, error)
RememberForever(key string, callback func() any) (any, error)

// After
Remember(key string, ttl time.Duration, callback func() (any, error)) (any, error)
RememberForever(key string, callback func() (any, error)) (any, error)

9. Change The Package Name Of access.NewAllowResponse and access.NewDenyResponse(If using)

Change /contracts/auth/access to /auth/access:

// Before
import "github.com/goravel/framework/contracts/auth/access"

access.NewAllowResponse()
access.NewDenyResponse()

// After
import "github.com/goravel/framework/auth/access"

access.NewAllowResponse()
access.NewDenyResponse()

10. Remove Deprecated Methods(If using)

  1. Remove ctx.Request().Form() and ctx.Request().Json() methods, use the ctx.Request().Input() method instead;

  2. Remove GetLevel, GetTime, GetMessage methods of Log custom driver, use Level, Time, Message methods instead;

  3. Remove the gorm.New method, the method is used to obtain the gorm instance directly, it is no longer recommended. if necessary, use the gorm.NewGormImpl method instead;

Function Introduction

Seeding

Version: v1.13.1

For Detail

Factories

Version: v1.13.1

For Detail

Testing

Version: v1.13.1

For Detail

Views

Version: v1.13.1

For Detail

Upgrade The Default Version Of Golang To 1.20

Version: v1.13.1

Golang 1.18 and 1.19 have been discontinued and the framework has been upgraded to 1.20 accordingly, for detail. If you want to continue using 1.18 or 1.19, just modify the version number in go.mod, they are fully compatible at present.

Task Scheduling Supports Scale Horizontally

Version: v1.13.1

For Detail

Add debug Methods

Version: v1.13.1

For Detail

make:controller Command Adds Parameter

Version: v1.13.1

The make:controller command adds --resource parameter, the CURD struct can be created easily:

go run . artisan make:controller --resource UserController

Add Status method for Response

Version: v1.13.1

For Detail

Add Sum and Cursor methods for Orm

Version: v1.13.1

For Detail

The Route Module Supports Configure Driver

Version: v1.13.1

Separate the original default driver Gin of the Route module into a package, it can be injected into Goravel by configuration. after this optimization, providers a convenient channel for injecting other HTTP packages into Goravel, currently two HTTP packages are officially supported:

DriverLink
Ginhttps://github.com/goravel/gin
Fiberhttps://github.com/goravel/fiber

Add InputArray And InputMap Methods For Request

Version: v1.13.1

For Detail

The Model Of Orm Supports Custom Connection

Version: v1.13.1

For Detail

Add Cloudinary Driver For Filesystem

Version: v1.13.1

For Detail

Add New Chain Methods For Log

Version: v1.13.1

For Detail

Fix facades.Auth().User()

Version: v1.13.1

  1. Fix the problem that no error throws if the user didn't exist when using the facades.Auth().User(ctx, &user) method.

  2. Fix the problem that user can be found when the primary key isn't int;

Fix Custom .env Path Does Not Take Effect In Some Cases

Version: v1.13.1

Fix the problem that custom .env path does not take effect in some cases.

Fix Token Expires Immediately When ttl == 0 Is Set In JWT

Version: v1.13.1

Expect the token to never expire when ttl == 0.

Fix facades.Storage().Url() Returns Wrong Path Under Windows

Version: v1.13.2

Issue #263

Fix Abnormal Connection When The Postgres Password Is Empty

Version: v1.13.2

Issue #270

Fix The With Method Is Invalid When Using The Cursor Method Of Orm

Version: v1.13.2

Issue #253

The Service Startup Supports Environment Variables

Version: v1.13.4

Issue #265

Fix The Validation Module Cant Verify The Route Params

goravel/gin: v1.1.6

goravel/fiber: v1.1.11

Issue #294

Fix The Fiber Driver Cant Return File

goravel/fiber: v1.1.11

Issue #299

Fix The Global Middleware Of Fiber Driver Panic

goravel/fiber: v1.1.11

Issue #300

Fix The ContentType Setting Of Fiber Driver Is Different From Gin Driver

goravel/fiber: v1.1.11

Issue #296

Fix The Connection Of Model Does Not Work

goravel/framework: v1.13.5

Issue #312

Fix The Error Of Mock Log

goravel/framework: v1.13.5

Issue #320

Fix The Problem Of Nonlinear Execution Of Query Chain

goravel/framework: v1.13.6 v1.13.7

Issue #341

Fix The Problem Of facades.Auth().Parse()

goravel/framework: v1.13.8

Issue #388

Fix The Problem of facades.Orm().WithContext()

goravel/framework: v1.13.8

Issue #390

The Queue Log Is Controlled By APP_DEBUG

goravel/framework: v1.13.8

The Debug and Info levels will not be print when APP_DEBUG=false

Issue #389

Fix The Problem Of The New Line Print Of Log Is Incorrect

goravel/framework: v1.13.9

Issue #395

Fix The Problem Of The vendor:publish Commabnd Can Not Publish Directory

goravel/framework: v1.13.9

Issue #345

Fix The Traces Do Not Cleaned When Calling Log.Info After Log.Error

goravel/framework: v1.13.10

Issue #402

Fix The GetAttribute Of Orm Event Returns Error Data

goravel/framework: v1.13.10

Issue #405

Add ToSql, ToRawSql Methods For ORM

goravel/framework: v1.13.10

Issue #411

Edit this page