Skip to content

How to run Laravel for Go locally on Windows, macOS or Linux with EnvKit

Create a Laravel for Go (beta) app in EnvKit: Go 1.27+, the Laravel CLI and PostgreSQL, MySQL or SQLite set up for you, served at https://name.test.

EnvKit6 min read
Laravel for Go, one click in EnvKit, with the Laravel, Go and EnvKit logos
On this page

On December 2 Laravel released the first beta of Laravel for Go (Laravel calls it Laravel Go), one day after Laravel for Rust. It is a full-stack framework written in plain, idiomatic Go: routing, middleware, sessions, authentication, models, queues, mail and testing helpers, with Inertia and React on the front end. You create an app with the Laravel CLI and laravel new <name> --go, and a release build is a single binary.

This post shows how to get one running on your own machine with EnvKit, step by step, and what to do with it afterwards. If you want the short version, there is an overview on the Laravel for Go page.

What you need

  • EnvKit 1.0.4 or newer. It's free and needs no account.
  • Windows 10 or 11 on x64, macOS on Apple Silicon, or Linux x86_64.

That's it. You don't need Go, Node.js, Git or the Laravel CLI installed beforehand, and you don't need a C compiler: Go builds the app on its own, and the SQLite driver the framework uses is pure Go. On Windows that means no Visual Studio, which is the part that makes Laravel for Rust heavy to set up by hand.

What it takes without EnvKit

For comparison, this is the manual route:

  1. Install Go 1.27 or newer (the framework's go.mod asks for 1.27).
  2. Install Node.js and Git.
  3. Install the Laravel CLI 0.4.0 or newer.
  4. Install a database server, start it and create a database.
  5. Run laravel new shop --go.
  6. Edit bootstrap/app.go so the Drivers list has the driver for your database, then go mod tidy.
  7. Put a DATABASE_URL in .env that matches your server's user, port and database.
  8. Build, migrate, and run laravel dev.

None of it is hard, but each step is a place to get stuck, and step 6 is easy to miss: the starter lists only the Postgres driver, so for MySQL or SQLite you have to swap it yourself.

Create the app

In EnvKit, open Sites, click New project and pick Laravel (Go). It has a Beta badge. The dialog is called "New Laravel (Go) app" and asks for two things:

  1. A project name. It becomes the folder and the address: shop is served at https://shop.test.
  2. A database. PostgreSQL is the default. MySQL / MariaDB and SQLite are the other choices. PostgreSQL and MySQL run inside EnvKit; SQLite is a file in the project and needs no server.

Before you press Create app, the dialog shows what it found on your machine and what it will install. If your Go is 1.27 or newer, it uses that. If not, it installs EnvKit's own Go runtime into EnvKit's data folder and leaves your system Go alone. Node.js, Git and the Laravel CLI work the same way.

Then the checklist runs, one step at a time, with "Step N of M" and an output panel you can open:

text
Go 1.27+           your Go if new enough, else EnvKit's Go runtime
Node.js, Git, Laravel CLI 0.4.0
Database           PostgreSQL / MySQL / SQLite, database created
laravel new shop --go
bootstrap/app.go   database driver set, then go mod tidy
.env               APP_URL=https://shop.test, DATABASE_URL for EnvKit's server
go build
migrate --force
laravel dev        https://shop.test

The first build downloads the Go modules and compiles the app. That can take a minute or two. Later builds take seconds. When it's done the dialog says "Your Laravel (Go) app is live", with the Go version the app runs on and how long laravel new and the build took.

If a step fails, the dialog names the step and removes what that run made: the folder, the site and the database. Fix the cause (a full disk, a port taken by another program) go back and run it again; there is nothing to clean up by hand.

How the app runs

EnvKit runs the app with laravel dev as the site's dev process. That one command starts the web server, a queue worker and Vite. EnvKit sets SERVER_HOST and SERVER_PORT on the process, picks a free port so two apps never fight over 8000, and puts the app behind https://shop.test with a trusted certificate.

The server restarts when a .go file changes. So the loop is the one you know from PHP Laravel: edit, save, reload the browser.

Day-to-day commands

The site page has a Laravel (Go) section:

  • Prepare installs anything that's missing, builds the app and starts laravel dev. Run it again after you change go.mod or switch the database.
  • Migrate runs the migrations.
  • Route list shows the app's routes as a table (Method, URI, Handler) with a filter and a Copy button.
  • Build release runs npm run build and then go build -o app ..
  • Dev log shows the output of laravel dev.

The site's terminal has Go, the Laravel CLI and Git on the PATH, so the usual commands work there too:

Terminal
laravel migrate
laravel route:list

There is no PHP in a Laravel for Go app, so there's no Tinker and no Composer step. Migrations, routes and console commands compile into the program itself.

Switching the database later

The database lives in two places: the driver list in bootstrap/app.go and DATABASE_URL in .env. If you started on SQLite and want PostgreSQL, the simplest path is a new app with PostgreSQL picked in the dialog. For an existing app, change the driver in the Drivers list of bootstrap/app.go so it lists only the one you want, then press Prepare on the site page. Prepare reads that driver, shows the DATABASE_URL it suggests for EnvKit's server (it changes .env only when you tick it), creates the database if it doesn't exist, rebuilds and restarts laravel dev.

An app you already have

If you cloned a Laravel for Go app from a teammate or started one by hand, add it with Sites → Add existing project, or clone it with Clone from Git. EnvKit recognises it from go.mod (it requires go.laravel.com) and opens it on its site page. If it isn't ready to run, the page says so and offers Prepare, which installs what's missing, fills in .env, creates the database, builds the app and starts it. Migrations only run if you tick them.

Building and deploying

Build release gives you one binary: app, or app.exe on Windows. Where you run it is up to you.

If you'd rather not do that by hand, Deploy to Evorxa handles Laravel for Go apps on a plain Ubuntu or Debian server. EnvKit installs Go and Node on the server, builds the front end and the binary, writes a production .env (and generates APP_KEY if it's missing), creates the database and runs bin/app migrate --force. The app runs as a systemd service behind nginx with SSL and the /up health check, plus the queue worker and the scheduler when the app uses them.

Limits of the beta

  • Laravel for Go sends mail through Resend, SES or the log. It has no SMTP mailer yet, so Mailpit can't catch it. In development the mail goes to the log.
  • The framework is pre-1.0. An upgrade can change its APIs.
  • EnvKit's support is a beta too. If something goes wrong on your machine, please open an issue with the step that failed and its output.

Laravel for Go or Laravel for Rust?

Both are new and both run in EnvKit the same way. The practical difference on a dev machine is the toolchain: Laravel for Rust needs a C compiler (EnvKit installs MinGW-w64 on Windows for it) and its first build takes several minutes, while Laravel for Go needs only Go and builds in a minute or two. Laravel's own announcement says Go trades a little of Rust's top-end speed for much faster compile times. If you want to try both, the Laravel for Rust walkthrough covers the other one.

The EnvKit docs have a Laravel for Go section, and the 1.0.4 release notes list everything else that shipped with it. For the framework itself, start with Laravel's Laravel Go docs.

Get EnvKit

EnvKit is a free desktop app for Windows, macOS and Linux that runs your local web stack: web servers, PHP, databases, Node, and now Laravel for Go and Laravel for Rust, each project at a trusted .test address. If you try the Laravel (Go) flow, tell us how it went.

Try it on your own projects

EnvKit is free, with no account. nginx or Apache, several PHP versions, MySQL, PostgreSQL, Redis, Node and trusted .test HTTPS from one app.

Or install from the terminal
irm https://envkit.net/install.ps1?c=blog-laravel-for-go-in-envkit | iex

More from the blog

All posts →