Upgrading To v1.12 From v1.11

v1.12.6

Bug Fixes ๐Ÿ›

v1.12.5

Bug Fixes ๐Ÿ›

v1.12.4

Bug Fixes ๐Ÿ›

v1.12.3

Bug Fixes ๐Ÿ›

v1.12.2

Bug Fixes ๐Ÿ›

v1.12.1

Bug Fixes ๐Ÿ›

v1.12.0

Exciting New Features ๐ŸŽ‰

Enhancements ๐Ÿš€

Breaking Changes ๐Ÿ› 

Upgrade Guide

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

Estimated Upgrade Time: 30 Minutes

1. Updating Dependencies

Update dependencies in the go.mod file:

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

There is an error after running go mod tidy, the error will be solved after performing the following upgrade steps.

2. Modify bootstrap/app.go

// Before
app := foundation.Application{}

// After
app := foundation.NewApplication()

3. Modify facades.*

BeforeAfter
facades.Artisanfacades.Artisan()
facades.Authfacades.Auth()
facades.Cachefacades.Cache()
facades.Configfacades.Config()
facades.Cryptfacades.Crypt()
facades.Eventfacades.Event()
facades.Gatefacades.Gate()
facades.Grpcfacades.Grpc()
facades.Hashfacades.Hash()
facades.Logfacades.Log()
facades.Mailfacades.Mail()
facades.Ormfacades.Orm()
facades.Queuefacades.Queue()
facades.RateLimiterfacades.RateLimiter()
facades.Routefacades.Route()
facades.Schedulefacades.Schedule()
facades.Storagefacades.Storage()
facades.Validationfacades.Validation()

4. Modify app/providers/*

Add import for all files:

import (
  "github.com/goravel/framework/contracts/foundation"
)

All of Register, Boot methods Add app foundation.Application input parameter:

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

func (receiver *AppServiceProvider) Boot(app foundation.Application) {}

5. Modify app/config/app.go

Modify import:

// Before
"github.com/goravel/framework/contracts"

"providers": []contracts.ServiceProvider{

// After
"github.com/goravel/framework/contracts/foundation"

"providers": []foundation.ServiceProvider{

6. Modify Flag in the Artisan command(If using)

The items in the []command.Flag add &command.StringFlag type:

// Before
func (receiver *VendorPublishCommand) Extend() command.Extend {
  return command.Extend{
    Category: "test",
    Flags: []command.Flag{
      {
        Name: "test",
      },
    },
  }
}

// After
func (receiver *VendorPublishCommand) Extend() command.Extend {
  return command.Extend{
    Category: "test",
    Flags: []command.Flag{
      &command.StringFlag{
        Name: "test",
      },
    },
  }
}

7. Filesystem Module Cancels Default Support For S3, OSS, COS, Minio

In order to reduce the loading of unnecessary third packages, reduce package volume, and improve compilation efficiency, Goravel will gradually strip each module driver into an independent expansion packages. In this upgrade, the Filesystem module cancels the default support for S3, OSS, COS, Minio drivers, and transfers support to independent extension packages.

Removes keys in config/filesystems.go::disks except local and drivers which are using:

// Modified
"disks": map[string]any{
  "local": map[string]any{
    "driver": "local",
    "root":   "storage/app",
    "url":    config.Env("APP_URL", "").(string) + "/storage",
  },
},

If you are using other drivers expect local, please refer to the corresponding driver documentation for installation:

DriverLink
S3https://github.com/goravel/s3open in new window
OSShttps://github.com/goravel/ossopen in new window
COShttps://github.com/goravel/cosopen in new window
Miniohttps://github.com/goravel/minioopen in new window

8. Cache Module Cancels Default Support For Redis

Remove the redis key in config/cache.go::stores if you are not using it:

// Modified
"stores": map[string]any{
  "memory": map[string]any{
    "driver": "memory",
  },
},

If you are using the redis driver, please refer to the redis driver documentation for installation:

DriverLink
Redishttps://github.com/goravel/redisopen in new window

9. Change The Type Of CreatedAt, UpdatedAt In Model(If using)

In order to make the time type more standard in API output, the type of CreatedAt, UpdatedAt in Model change to carbon.DateTime from time.Time. If you have additional processing for these two fields, you can get the original time.Time type through the CreatedAt.ToStdTime() method.

10. Optimize The Rule Of Validation Module(If using)

Check the zero value in the original validate rule, for example, if the rule is set to date and required is not set, and the field is empty or not passed, the validation module will prompt that field is required. After optimization, the validation module will passed the check, which is more intuitive to use. If you are using relevant validation, please ensure that the upgrade is as expected.

11. Install dependencies again

Run go mod tidy

Function Introduction

Service Container

Version: v1.12.0

All services in Goravel are registered in the service container, providing strong support for the package development, For Detail

Package Development

Version: v1.12.0

Packages are the primary way of adding functionality to Goravel, can enrich the ecology of Goravel, For Detail

Artisan Flag Adds New Methods

Version: v1.12.0

Add methods for Artisan module to get different types of Flag, For Detail

Add Helpers Methods

Version: v1.12.0

Add path and carbon Helpers methods, you can easily get the path information and deal with time in project, For Detailใ€‚

Upgrade Dependencies

Version: v1.12.0

To provide better feature support, the versions of all packages that Goravel depends on have been upgraded.

Migration Adds New Methods

Version: v1.12.0

CommandsAction
migrate:freshDrop all tables and re-run all migrations
migrate:refreshReset and re-run all migrations
migrate:resetRollback all database migrations
migrate:statusShow the status of each migration

Some make Commands Support Subdirectories

Version: v1.12.0

ๅ‘ฝไปค็”Ÿๆˆๆ–‡ไปถ
make:policy User/AuthPolicyapp/policies/User/auth_policy.go
make:command Goravel/CleanCacheapp/console/commands/Goravel/clean_cache.go
make:model User/Phoneapp/models/User/phone.go
make:observer User/PhoneObserverapp/observers/User/phone_observer.go
make:event User/GoravelEventapp/events/User/goravel_event.go
make:listener User/GoravelListenapp/listeners/User/goravel_listen.go
make:controller User/AuthControllerapp/http/controllers/User/auth_controller.go
make:middleware User/Authapp/http/middleware/User/auth.go
make:request User/Authapp/http/requests/User/auth.go
make:job Goravel/Jobapp/jobs/Goravel/job.go
make:rule User/Phoneapp/rules/User/phone.go

The Panic Problem Caused By File Path Under Windows

Version: v1.12.1

Fix the panic problem caused by backslash when the make command automatically creates folders under Windows.

The Problem Of facades.Gate() Return nil

Version: v1.12.2

Fix the problem of facades.Gate() return nil.

The Problem Of make:package Command Under Windows

Version: v1.12.3

The file created by the make:package command has a wrong path under Windows.

The Problem Of The Throttle Middleware Throw Panic

Version: v1.12.4

Fix the problem of the throttle middleware throw panic.

Fix The Problem Of facades.Orm().Query().Load()

Version: v1.12.5

Fix the problem that facades.Orm().Query().Load() cannot load the model correctly in some cases.

Fix The Problem Of JWT

Version: v1.12.6

Fix the problem that when the JWT Token is expired and invalid, the expiration error is returned, and the invalid error is expected to be returned first.