LaraflareDocsPackages13.x

Docs / Getting Started / Installation

Installation

Meet Laraflare

Laraflare is a web application framework for Cloudflare Workers, written in TypeScript. Its classes, methods and console commands follow the framework they were ported from, so routing, Eloquent models, queues, mail and the rest work the way you would expect; where a Worker or D1 can't do something, the page for that feature says so.

Creating an Application

Install the laraflare command once, then create an application with it:

npm install -g @laraflare/installer

laraflare new example-app

Or, without installing anything first:

npx @laraflare/installer new example-app

The installer asks for the application's name and database (SQLite, or MySQL), fetches the framework and copies its starter, writes the env files and the Worker configs, installs the packages, runs the first migration and seeds the owner's account. Sign in as admin with the password in .env (OWNER_PASSWORD).

The installer takes the usual options: --database=sqlite|mysql, --git (with --branch=main), --npm (runs npm run build), --pnpm, --yarn or --bun (installs and builds with that package manager instead), --force and --no-interaction. There is one starter kit, Vue, so --vue is accepted and changes nothing. With --no-owner it writes no owner credentials and seeds no account, leaving a plain application. With --boost it adds @laraflare/boost to the application's development dependencies and runs boost:install; --no-boost skips the question.

Inside an application, the same command runs it: laraflare dev starts local development, and every console command can be given to it, so laraflare migrate is npx artisan migrate.

Local Development

Valet

Valet is the preferred way to run Laraflare applications on a Mac. When the application's folder is in a folder Valet parks, the installer secures the site, and https://example-app.test serves it. The first visit starts the application's dev server (scripts/dev.ts) in the background and shows a page that reloads once it is ready; after that, every change is rebuilt as you save. Nothing has to be started by hand.

If the folder isn't parked yet, park it and secure the site:

cd ~/Sites
valet park
cd example-app
valet secure

Herd

Herd works the same way: it reads the application's LocalValetDriver.php, and the installer runs herd secure when Valet isn't installed.

Without Valet or Herd

Run the dev server yourself. It builds the application, serves it at http://127.0.0.1 on the port in scripts/dev.ts, and rebuilds on every change:

npm run dev

You may also serve the application without rebuilding:

npx artisan serve

Environment Files

Each environment has its own env file: .env for your machine, .env.staging and .env.production for the deployed Workers. They hold the same names in the same order, and each has its own APP_KEY. The staging and production files are committed encrypted (.env.staging.encrypted, .env.production.encrypted); the key that opens them, ENV_ENCRYPTION_KEY, is kept outside the project.

Next Steps

When the application is ready to go live, read the deployment documentation.