Upgrading To v1.13 From v1.12

Exciting New Features 🎉

Enhancements 🚀

v1.13.4

Breaking Changes 🛠

Bug Fixes 🐛

v1.13.2

v1.13.4

v1.13.5

v1.13.6 v1.13.7

v1.13.8

v1.13.9

v1.13.10

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

testsopen in new window

database/seeders/database_seeder.goopen in new window

app/providers/database_service_provider.goopen in new window

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.goopen in new window

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.goopen in new window

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 detailopen in new window. 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/ginopen in new window
Fiberhttps://github.com/goravel/fiberopen in new window

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 Detailopen in new window

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 #263open in new window

Fix Abnormal Connection When The Postgres Password Is Empty

Version: v1.13.2

Issue #270open in new window

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

Version: v1.13.2

Issue #253open in new window

The Service Startup Supports Environment Variables

Version: v1.13.4

Issue #265open in new window

Fix The Validation Module Cant Verify The Route Params

goravel/gin: v1.1.6

goravel/fiber: v1.1.11

Issue #294open in new window

Fix The Fiber Driver Cant Return File

goravel/fiber: v1.1.11

Issue #299open in new window

Fix The Global Middleware Of Fiber Driver Panic

goravel/fiber: v1.1.11

Issue #300open in new window

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

goravel/fiber: v1.1.11

Issue #296open in new window

Fix The Connection Of Model Does Not Work

goravel/framework: v1.13.5

Issue #312open in new window

Fix The Error Of Mock Log

goravel/framework: v1.13.5

Issue #320open in new window

Fix The Problem Of Nonlinear Execution Of Query Chain

goravel/framework: v1.13.6 v1.13.7

Issue #341open in new window

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

goravel/framework: v1.13.8

Issue #388open in new window

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

goravel/framework: v1.13.8

Issue #390open in new window

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 #389open in new window

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

goravel/framework: v1.13.9

Issue #395open in new window

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

goravel/framework: v1.13.9

Issue #345open in new window

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

goravel/framework: v1.13.10

Issue #402open in new window

Fix The GetAttribute Of Orm Event Returns Error Data

goravel/framework: v1.13.10

Issue #405open in new window

Add ToSql, ToRawSql Methods For ORM

goravel/framework: v1.13.10

Issue #411open in new window