Upgrading To v1.11 From v1.10

v1.11.3

Bug Fixes 🐛

v1.11.2

Bug Fixes 🐛

v1.11.1

Exciting New Features 🎉

Bug Fixes 🐛

v1.11.0

Exciting New Features 🎉

Enhancements 🚀

Breaking Changes 🛠

Bug Fixes 🐛

  • The problem that the hashing configuration does not take effect under some situations(1.11.0)
  • Non-thread safety problems in RateLimiter(1.11.0)

Upgrade Guide

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

Estimated Upgrade Time: 1 Minutes

Updating Dependencies

Update dependencies in the go.mod file:

go get -u github.com/goravel/framework@v1.11.0 && go mod tidy
go get -u github.com/goravel/framework@v1.11.0 && go mod tidy

2. Remove deprecated methods

import (
  "github.com/goravel/framework/database"
  "github.com/goravel/framework/database/gorm"
)

// Deprecated
database.NewGormInstance()
// Replace with(Note: This method is not recommended, please try not to use it)
gorm.New()

// Deprecated
facades.Orm.Query().Updates()
// Replace with(Only modify the method name is fine, no need to modify the parameters)
facades.Orm.Query().Update()

// The Update method changes return value
// Before
err := facades.Orm.Query().Update()
// After
res, err := facades.Orm.Query().Update()

New Content

This section does not involve code changes, only enhancements.

Orm add model events

Version: v1.10.1

Orm models dispatch several events, allowing you to hook into the following moments in a model's lifecycle: Retrieved, Creating, Created, Updating, Updated, Saving, Saved, Deleting, Deleted, ForceDeleting, ForceDeleted.

For Detail

Cache add and optimize methods

Version: v1.10.1

New Methods

MethodsAction
DecrementDecrement
IncrementIncrement
LockAtomic Locks
StoreAccessing Multiple Cache Stores

Optimize methods

Get, GetBool, GetInt, GetInt64, GetString, Pull no longer need to pass a default value(Backwards compatible).

Route supports Fallback route

Version: v1.10.1

You may define a route that will be executed when no other route matches the incoming request.

facades.Route.Fallback(func(ctx http.Context) http.Response {
  return ctx.Response().String(404, "not found")
})

Orm adds new methods

Version: v1.10.1

MethodAction
db.RawRaw Expressions
LockForUpdatePessimistic Locking
SharedLockPessimistic Locking

Optimize facades.Config.Add()

Version: v1.11.0

The configuration parameter of facades.Config.Add() changes to any from map[string]any, make configuration more flexible.

For Detail

Change Sqlite driver

Because github.com/mattn/go-sqlite3 requires CGO to be started, so replacing a third-party package that does not require CGO: github.com/glebarez/go-sqlite.

contracts/http add method mapping of net/http

Version: v1.11.0

You can use http.MethodGet in controller directly, instead of import net/http.

For Detailopen in new window

Route Add Resource Routing

Version: v1.11.1

facades.Route.Resource("/resource", resourceController)

For Detail

Request Add New Methods

Version: v1.11.1

MethodAction
AllRetrieving all input data
HostRetrieving the request HOST
QueriesRetrieving input from the query string

About to be deprecated the Form, Json methods, please use Input instead.

Storage Add New Methods

Version: v1.11.1

MethodAction
LastModifiedGet the last modified time of file
MimeTypeGet the mime type of file

File Add New Methods

Version: v1.11.1

MethodAction
LastModifiedGet the last modified time of file
MimeTypeGet the mime type of file
SizeGet the size of file

Fix The Error Of Incorrect Windows Path For Filesystem

Version: v1.11.1

There is a wrong slash in windows system.

Fix The Panic Of The Header Method For Request

Version: v1.11.1

ctx.Request().Header( key: "token") will panic.

Fix The Data Error Of Using Request.Input() And Request.Bind() At The Same Time

Version: v1.11.2

Request.Input() will clear Request.Body, if you use Request.Bind() after that, you will not be able to get the data correctly.

The problem of process interruption caused by panic in Schedule

Version: v1.11.3

The Schedule process will interruption when occurring panic, all tasks wil lbe affected.

The problem that DailyAt in Schedule will be executed every minute

Version: v1.11.3

Fix the problem that DailyAt will be executed every minute:

func (kernel *Kernel) Schedule() []schedule.Event {
  return []schedule.Event{
    facades.Schedule.Call(func() {
      fmt.Print("1")
    }).DailyAt("18:00"),
  }
}