Installation
Meet Laravel
Laravel for Go is currently in beta. Releases before 1.0 may include breaking changes to APIs and configuration.
Laravel for Go is a full-stack web application framework. It includes the routing, middleware, sessions, database tools, queues, and testing helpers that every web application needs, so you can spend your time on what your application does.
Laravel is built on Go's standard net/http package, which gives it a solid foundation: each request runs in its own goroutine, so a request waiting on the database or another service never holds up the rest. Your application is an http.Handler, each request embeds the standard *http.Request, and you may use the handlers and middleware that other Go libraries provide. On that foundation, Laravel adds a variety of full-stack features for building ambitious applications, from authentication and validation to queues, mail, notifications, and broadcasting.
Creating an application
Before you create your first Laravel application, install Go, Node.js, and Git on your machine.
Laravel needs Go 1.27 or later. If you don't have Go yet, download the installer for your operating system from the Go website. If you already have Go, run go version to check which release you have.
Your application's frontend is built with Node.js. Download the LTS release from the Node.js website, which offers graphical installers for macOS and Windows. Most machines already have Git. If yours doesn't, download it from the Git website.
Installing the Laravel CLI
The Laravel CLI creates new applications and runs your application's commands. On macOS and Linux, install it with this command:
1curl -fsSL https://laravel.com/install.sh | sh1curl -fsSL https://laravel.com/install.sh | sh
On Windows, run this command in PowerShell instead:
1powershell -ExecutionPolicy Bypass -c "irm https://laravel.com/install.ps1 | iex"1powershell -ExecutionPolicy Bypass -c "irm https://laravel.com/install.ps1 | iex"
The installer puts the laravel command in ~/.laravel/bin and adds that directory to your PATH, so open a new terminal before you use it. When a newer version of the CLI comes out, laravel new tells you and offers to update it for you.
Resolving PATH conflicts
Laravel Herd and the older Composer-based Laravel installer also provide a laravel command. If you have either installed, open a new terminal and check which binary your shell finds first:
1laravel --version1laravel --version
The output should start with Laravel CLI. If it prints a different installer's version, another directory appears ahead of ~/.laravel/bin on your PATH. You can inspect every laravel binary on your PATH by running which -a laravel on macOS and Linux, or Get-Command laravel -All in PowerShell on Windows.
To put the new Laravel CLI first on macOS and Linux, move the PATH line the installer added to your shell profile (such as ~/.zshrc or ~/.bashrc) below any Herd or Composer PATH entries. If you installed the older installer with Composer and no longer need it, you may also remove it with composer global remove laravel/installer. On Windows, move %USERPROFILE%\.laravel\bin above Herd's or Composer's directory in your user Path environment variable. Then open a new terminal and run laravel --version again to confirm.
Creating your application
Now create your application with laravel new. When it asks which language you'd like to use, choose Go. If you'd rather skip the question, such as in a script, pass --go:
1laravel new example-app2cd example-app1laravel new example-app2cd example-app
The CLI downloads a new application into the example-app directory, creates its .env file, installs its frontend dependencies, and compiles it, so your first command starts right away. Your new application comes set up with Inertia, React, TypeScript, Tailwind, and Vite Plus.
The CLI also generates your application's encryption key and sets it as APP_KEY in .env. This key encrypts your cookies and sessions, so keep it secret. To change it later, follow the key rotation guide.
Your .env file holds the settings that change between your machine and your servers, such as database URLs and API keys. Since it holds your secrets, don't commit it to source control. To learn more about .env and the settings Laravel reads from it, check out the configuration guide.
Your application's Go module is always named app, whatever you call your project, so imports of your own packages start with app/, such as app/models.
Databases and migrations
Your application stores its users, queued jobs, and other data in a database, so set one up before you start the application. New applications default to PostgreSQL, and we recommend developing against the same database you plan to run in production so your queries, migrations, and tests behave the same way. By default, your .env file connects to a local PostgreSQL database named laravel:
If you don't have PostgreSQL installed locally yet, DBngin (macOS and Windows) and Postgres.app (macOS) let you start a local PostgreSQL server in a few clicks.
If your PostgreSQL server uses another user, password, or port, change this URL to match. To learn more about this setting, check out the database guide's section on configuration. Then run your migrations from your application's directory to create the users, sessions, and queue tables:
1laravel migrate1laravel migrate
If the database doesn't exist yet, migrate offers to create it.
You may use SQLite, MySQL, or MariaDB instead. In bootstrap/app.go, replace postgres.Driver in the Drivers list with sqlite.Driver or mysql.Driver, and import that driver's package, go.laravel.com/db/sqlite or go.laravel.com/db/mysql, in place of db/postgres. Your new application's go.sum only lists the PostgreSQL driver's dependencies, so run go mod tidy to add the new driver's:
1go mod tidy1go mod tidy
Then point .env at your database:
1DATABASE_URL=sqlite:storage/database.sqlite1DATABASE_URL=sqlite:storage/database.sqlite
Laravel creates the SQLite file the first time your application connects. Your application's migrations work on every supported database.
Running the application
Next, start your application with laravel dev, which starts your application, a queue worker, and Vite Plus all at once:
1laravel dev1laravel dev
Once the application starts, visit http://127.0.0.1:8000 in your browser to see its welcome page. When you change a .go file or your .env file, your application rebuilds and restarts, and the page in your browser refreshes once the server is back.
While Vite runs, your frontend edits appear in the browser through hot reloading, and the page refreshes when you edit a view in resources/views/.
Your application has console commands of its own, such as route:list, which lists your routes. Run them through laravel from your application's directory or any directory inside it. The CLI compiles your application first, and only shows the compiler's output when the build fails:
1laravel route:list1laravel route:list
To see every command your application has, run laravel list.
To check your frontend's formatting, lint rules, and types, run npm run check. To apply the fixes it can make, run npm run check:fix.
Running in production
When you're ready to see how your application runs in production, stop laravel dev, build your frontend assets, and build your application into a single binary. Then run the binary:
1npm run build2go build -o app .3./app1npm run build2go build -o app .3./app
If you use Inertia server-side rendering, set INERTIA_SSR=true and build with npm run build:ssr instead. Then run node bootstrap/ssr/app.js alongside your application.
When you're ready to put your application on a server, the deployment guide walks you through building, configuring, and running it in production.
Before you deploy, check that APP_ENV is production and APP_DEBUG is false. With debug mode on, a server error's page shows the error's message and a panic's stack trace, for anyone to see.
Health checks
Load balancers and uptime monitors often need a way to tell whether your application is running. Your application answers these health checks at /up, which responds with a 200 once your application has started. The route's path is set in bootstrap/app.go, where you may change it:
1Routes: laravel.Routes{2 Web: routes.Web,3 API: routes.API,4 Channels: routes.Channels,5 Health: "/up",6},1Routes: laravel.Routes{2 Web: routes.Web,3 API: routes.API,4 Channels: routes.Channels,5 Health: "/up",6},
Point your load balancer or monitoring service at this URL. To learn more about how the health route answers, check out the routing guide's section on the health route.
Deploying to Laravel Cloud
When you're ready to put your Laravel Go application in front of real users, Laravel Cloud is the best place to run it. Laravel Cloud is a fully managed deployment platform from the team behind Laravel. It deploys your application each time you push to Git and includes:
- Autoscaling that follows your traffic, and scale-to-zero when your application is idle, so you only pay for what you use
- Preview environments for every pull request
- Managed MySQL and Postgres databases, and Valkey caches
- Managed queues whose workers scale with the jobs waiting
- Object storage for your application's files
- Managed WebSocket servers
To deploy your application, get started with Laravel Cloud.
Next steps
Now that your application is running, you may be wondering what to learn next. Start with these guides to see how a Laravel application fits together:
Once you're comfortable with the basics, you're ready to start building. These guides walk you through the pieces most applications use first, from defining routes and validating input to storing data and testing your work: