Upgrading To v1.13 From v1.12
Exciting New Features đ
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
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
v1.13.6 v1.13.7
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
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
The
tls
andcors
middleware have been integrated into the default HTTP driver, therefore,middleware.Cors()
andmiddleware.Tls()
in theapp/http/kernel.go
file need to be removed.The
facades.Route().GlobalMiddleware(http.Kernel{}.Middleware()...)
method in theapp/providers/route_service_provider.go
file moves toBoot
fromRegister
:
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)
Remove
ctx.Request().Form()
andctx.Request().Json()
methods, use thectx.Request().Input()
method instead;Remove
GetLevel
,GetTime
,GetMessage
methods ofLog
custom driver, useLevel
,Time
,Message
methods instead;Remove the
gorm.New
method, the method is used to obtain thegorm
instance directly, it is no longer recommended. if necessary, use thegorm.NewGormImpl
method instead;
Function Introduction
Seeding
Version: v1.13.1
Factories
Version: v1.13.1
Testing
Version: v1.13.1
Views
Version: v1.13.1
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
Add debug Methods
Version: v1.13.1
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
Add Sum and Cursor methods for Orm
Version: v1.13.1
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:
Driver | Link |
---|---|
Gin | https://github.com/goravel/gin |
Fiber | https://github.com/goravel/fiber |
Add InputArray And InputMap Methods For Request
Version: v1.13.1
The Model Of Orm Supports Custom Connection
Version: v1.13.1
Add Cloudinary Driver For Filesystem
Version: v1.13.1
Add New Chain Methods For Log
Version: v1.13.1
Fix facades.Auth().User()
Version: v1.13.1
Fix the problem that no error throws if the user didn't exist when using the
facades.Auth().User(ctx, &user)
method.Fix the problem that
user
can be found when the primary key isn'tint
;
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
Fix Abnormal Connection When The Postgres Password Is Empty
Version: v1.13.2
Fix The With Method Is Invalid When Using The Cursor Method Of Orm
Version: v1.13.2
The Service Startup Supports Environment Variables
Version: v1.13.4
Fix The Validation Module Cant Verify The Route Params
goravel/gin: v1.1.6
goravel/fiber: v1.1.11
Fix The Fiber Driver Cant Return File
goravel/fiber: v1.1.11
Fix The Global Middleware Of Fiber Driver Panic
goravel/fiber: v1.1.11
Fix The ContentType Setting Of Fiber Driver Is Different From Gin Driver
goravel/fiber: v1.1.11
Fix The Connection Of Model Does Not Work
goravel/framework: v1.13.5
Fix The Error Of Mock Log
goravel/framework: v1.13.5
Fix The Problem Of Nonlinear Execution Of Query Chain
goravel/framework: v1.13.6 v1.13.7
Fix The Problem Of facades.Auth().Parse()
goravel/framework: v1.13.8
Fix The Problem of facades.Orm().WithContext()
goravel/framework: v1.13.8
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
Fix The Problem Of The New Line Print Of Log Is Incorrect
goravel/framework: v1.13.9
Fix The Problem Of The vendor:publish Commabnd Can Not Publish Directory
goravel/framework: v1.13.9
Fix The Traces Do Not Cleaned When Calling Log.Info After Log.Error
goravel/framework: v1.13.10
Fix The GetAttribute Of Orm Event Returns Error Data
goravel/framework: v1.13.10
Add ToSql, ToRawSql Methods For ORM
goravel/framework: v1.13.10