Goravel playground for Laravel devs
A small, working Goravel API for Laravel developers to clone, run and read. Open a controller, a model or a migration, and the Laravel version is written right above the Go.
An independent, unofficial project. Goravel is built and maintained by the Goravel team and contributors; this repository is not affiliated with or endorsed by them. For the full feature-by-feature comparison and everything else, read the Goravel documentation.
How it works
The app is a grassroots football club API (clubs, players, fixtures and a league table), and its application code carries short comments comparing each piece to Laravel. This is the club controller's Show action:
// Show returns one club, or 404.
//
// Laravel:
//
// public function show(Club $club): JsonResponse // route model binding
// {
// return response()->json(['data' => $club]);
// }
//
// Goravel: no route model binding, so findClub reads {id} and loads the row.
func (r *ClubController) Show(ctx http.Context) http.Response {
club, response := findClub(ctx)
if response != nil {
return response
}
return ctx.Response().Success().Json(http.Json{"data": club})
}
The comments cover the code a Laravel developer writes every day. The framework's own plumbing is left to the Goravel docs.
Where to look
- routes/api.goGroups, middleware, closures vs handlers
- ControllersNo injection, no route model binding
- Form requestsFamiliar rules, typed validated data
- ModelsStructs, relations as fields, no casts
- Migrations and factoriesSchema builder in Go
- PoliciesGates that do not know the user
- Jobs and eventsTyped arguments, no queue:work
- Artisan commandFlags as values, errors not exit codes
Run it
- Clone the repository and copy
.env.exampleto.env. make upstarts the app, MySQL and Redis in Docker.make artisan cmd="key:generate",make artisan cmd="jwt:secret", thenmake run.make freshloads a demo league; openhttp://localhost:8000/for every endpoint.make testruns the suite. Change some code and watch what breaks.