跳轉到內容

Compare With Laravel

Goravel is heavily inspired by the Laravel framework, aiming to bring similar elegance and simplicity to Go developers. Here are some key comparisons between Goravel and Laravel to help you understand how Goravel aligns with Laravel's features:

FeatureGoravelLaravelCode Example
Artisan Console./artisan key:generate
php artisan key:generate
Authenticationfacades.Auth(ctx).Login(&user)
Auth::login($user)
Authorizationfacades.Gate().Allows("update", user)
Gate::allows('update', $user)
Cachefacades.Cache().Put("key", "value", time.Minute)
Cache::put('key', 'value', 60)
Carboncarbon.Now().AddDays(1)
Carbon::now()->addDays(1)
Configfacades.Config().GetString("app.name")
config('app.name')
Cryptfacades.Crypt().EncryptString("text")
Crypt::encryptString('text')
DBfacades.DB().Table("users").Get(&users)
DB::table('users')->get()
Eventfacades.Event().Job(&events.Order{}).Dispatch()
Order::dispatch()
Factoryfacades.Orm().Factory().Make(&user)
User::factory()->make()
FileStoragefacades.Storage().Put("file.txt", "content")
Storage::put('file.txt', 'content')
Hashfacades.Hash().Make("password")
Hash::make('password')
Httpfacades.Route().Get("/", controller.Index)
Route::get('/', [Controller::class, 'index'])
Http Clientfacades.Http().Get("https://api.com")
Http::get('https://api.com')
Localizationfacades.Lang(ctx).Get("messages.welcome")
__('messages.welcome')
Loggerfacades.Log().Info("message")
Log::info('message')
Mailfacades.Mail().To("user@example.com").Send()
Mail::to('user@example.com')->send(new Order())
Mock
Migrate./artisan migrate
php artisan migrate
Ormfacades.Orm().Query().Find(&user, 1)
User::find(1)
Package Development
Processfacades.Process().Run("ls", "-la")
`Process::run('ls -la')
Queuefacades.Queue().Job(&jobs.Process{}).Dispatch()
Process::dispatch()
Rate Limitingfacades.RateLimiter().For("global", ...)
RateLimiter::for('global', ...)
Seederfacades.Seeder().Call([]seeder.Seeder{&User{}})
$this->call([User::class])
Sessionctx.Request().Session().Put("key", "value")
session(['key' => 'value'])
Task Schedulingfacades.Schedule().Command("emails:send").Daily()
Schedule::command('emails:send')->daily()
Testing
Validationctx.Request().ValidateRequest()
$request->validate()
Viewctx.Response().View().Make("welcome.tmpl")
view('welcome')
Grpc🚧
Notifications🚧
Broadcasting🚧
Livewire🚧

基於 MIT 许可發佈