关于laravel:在-Golang-中像-Laravel-的-Artisan-一样使用命令行Goravel-带你找回熟悉的味道

1次阅读

共计 1075 个字符,预计需要花费 3 分钟才能阅读完成。

Laravel 中的 Artisan 命令行是这样

// 创立命令
php artisan make:command SendEmails
// 运行命令
php artisan mail:send
// 应用参数
php artisan mail:send hello
// 应用选项
php artisan mail:send --mail=abc@qq.com

Goravel 中的 Artisan 命令行也一样

// 创立命令
go run . artisan make:command SendEmails
// 运行命令
go run . artisan mail:send
// 应用参数
go run . artisan mail:send hello
// 应用选项
go run . artisan mail:send --mail abc@qq.com

就连 struct 的定义都是满满的回顾:

package commands

import (
  "github.com/goravel/framework/contracts/console"
  "github.com/urfave/cli/v2"
)

type SendEmails struct {
}

//Signature The name and signature of the console command.
func (receiver *SendEmails) Signature() string {return "emails"}

//Description The console command description.
func (receiver *SendEmails) Description() string {return "Command description"}

//Extend The console command extend.
func (receiver *SendEmails) Extend() console.CommandExtend {return console.CommandExtend{}
}

//Handle Execute the console command.
func (receiver *SendEmails) Handle(c *cli.Context) error {return nil}

相熟的配方,原来的滋味。PHPer 极速切换,Goer 的福音。欢送 star 与 issues。

对于 Goravel

Goravel 是一个性能齐备、具备良好扩大能力的 Web 应用程序框架。作为一个起始脚手架帮忙 Golang 开发者疾速构建本人的利用。

我的项目地址:https://github.com/goravel/goravel

文档地址:www.goravel.dev

正文完
 0