Upgrading To v1.10 From v1.9

Exciting New Features ๐ŸŽ‰

Enhancements ๐Ÿš€

Breaking Changes ๐Ÿ› 

Upgrade Guide

Estimated Upgrade Time: 20 Minutes

Updating Dependencies

Update dependencies in the go.mod file:

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

Encryption

Version: v1.10.0

Add facades.Crypt:

  1. add &crypt.ServiceProvider{} to the providers item in the config/app.goopen in new window file;

For Detail

Hashing

Version: v1.10.0

Add facades.Hash:

  1. add &hash.ServiceProvider{} to the providers item in the config/app.goopen in new window file;

  2. Add config/hashing.goopen in new window file;

For Detail

Add Rate Limiting For Routing

Version: v1.10.0

For Detail

Optimize HTTP startup mode

Version: v1.10.0

  1. Add config/http.go configuration, For Detailopen in new window;
  2. The facades.Route.Run method no longer needs to pass parameters, by default use http.host and http.port(you don't need to modify the code, it's backward compatible);
  3. The facades.Route.RunTLS method no longer needs to pass parameters, by default use http.tls.host, http.tls.port, http.tls.ssl.cert and http.tls.ssl.key, if you are using it, you need to modify the code;
  4. Add facades.Route.RunTLSWithCert method, For Detail;
  5. Move app.url, app.host to http.url, http.host;

Optimize GRPC startup mode

Version: v1.10.0

The facades.Grpc.Run method no longer needs to pass parameters, by default use grpc.host and grpc.port(you don't need to modify the code, it's backward compatible);

Add configuration to control log output to console

Version: v1.10.0

Add print configuration to single, daily channel in the config/logging.go file, it can control log output to console, For Detailopen in new window;

Request modify and add methods

Version: v1.10.0

  1. The Input method is changed from only getting routing parameters to getting data according to the following order: json, form, query, routeใ€‚Note: json can only get one-dimensional data, otherwise it will return empty;
  2. Add Route method to replace the original Input method;
  3. The default value of Query and Form methods are modified to be unnecessary;
  4. Add methods as shown below:
MethodAction
RouteRetrieving An Route Value
RouteIntRetrieving An Route Value
RouteInt64Retrieving An Route Value
QueryIntRetrieving Input From The Query String
QueryInt64Retrieving Input From The Query String
QueryBoolRetrieving Input From The Query String
InputIntRetrieving An Input Value
InputInt64Retrieving An Input Value
InputBoolRetrieving An Input Value
JsonRetrieving Json

Queue support delayed dispatching

Version: v1.10.0

Add Delay method, For Detail

The Connection in ORM supports set table prefix and singular

Version: v1.10.0

  1. Model supports specify table name, For Detail;
  2. Add new keys to connection of config/database.go:

prefix: Set prefix for table name; singular: Set the table name to use singular or plural;

For Detailopen in new window

Add docker-compose.yml file

Version: v1.10.0

You can quickly start the service with the following command:

docker-compose build
docker-compose up

Optimize Orm

Version: v1.10.0

  1. Add the following methods:
FunctionsAction
FirstOrQuery or return data through callback
FirstOrNewRetrieving Or New Models
FirstOrFailNot Found Error
UpdateOrCreateUpdate or create
  1. An error was reported like this before, but now it's supported:
query := facades.Orm.Query()
query = query.Where()

Support multiple SQL in migration file

Version: v1.10.0

Previously, only one SQL statement was supported in the migration file, but now multiple statements are supported.

Add minio driver for File Storage

Version: v1.10.0

Add minio configuration, For Detailopen in new window.

contracts/http add status mapping of net/http

Version: v1.10.0

You can use status codes such as http.StatusOK directly in controller without importing net/http.

For Detailopen in new window

APP_KEY required

Version: v1.10.0

The APP_KEY in the .env file is changed to required, you can run command to generate the APP_KEY: go run . artisan key:generate.

Add ctx parameter to the methods under Form Request

Version: v1.10.0

Add ctx http.Context parameter to the methods under Form Request: Rules, Messages, Attributes, PrepareForValidation, allows you to do more custom configurations.

For Detail

facades.Auth.Parse add payload returns

Version: v1.10.0

err := facades.Auth.Parse(ctx, token) change to payload, err := facades.Auth.Parse(ctx, token), through payload you can get:

  1. Guard: Current Guard;
  2. Key: User flag;
  3. ExpireAt: Expire time;
  4. IssuedAt: Issued time;

For Detail

Some methods of Orm add new return values

Version: v1.10.0

The following methods add *Result return value to get the number of affected rows:

res, err := query.Delete(&user)
res, err := query.Exec(fmt.Sprintf("DELETE FROM users where id = %d", user.ID))
res, err := query.ForceDelete(&User{})
res, err := query.Updates(User{Avatar: "avatar"})

// Affected rows
num := res.RowsAffected