# Installation

## Meet Laravel Bash

Laravel Bash is a web application framework with expressive, elegant syntax, as long as your idea of elegant includes `"${@:2}"`. It gives you routing, controllers, an ORM, templates, validation, queues, events, broadcasting and a task scheduler, built from the small Linux programs that are already on your server.

### Why Laravel Bash?

- **Zero dependencies.** Apart from Bash 5, `socat`, `sqlite3`, `jq`, `awk`, `sort`, `join`, `flock`, `timeout` and Docker.
- **Share-nothing.** Every request is a brand new process, so there is no state to leak between requests, or anywhere else.
- **Proven technology.** Most of the programs Laravel Bash uses are older than PHP.

## Creating a Laravel Bash Application

### Installing Docker

Laravel Bash needs GNU tools and Bash 5.1 or later. macOS ships BSD tools and Bash 3.2, so Laravel Bash runs in Docker with [Sail](/docs/sail). Install [Docker Desktop](https://www.docker.com/products/docker-desktop/) or [OrbStack](https://orbstack.dev) first.

### Creating the application

```bash
git clone https://github.com/mrstebo/laravel-bash.git example-app
cd example-app
cp .env.example .env
./sail up -d
./sail artisan migrate --seed
```

Then open [localhost:8000](http://localhost:8000). The container runs `./artisan dev`, which starts the web server, four queue workers, the event listener and the scheduler, so the [examples](/examples) work straight away.

> [!NOTE]
> There is no Composer. There is no installer. There is `git clone`, which is how all software was installed before 2012.

## Initial Configuration

Configuration lives in `.env`, which is loaded line by line when the framework boots:

```bash
APP_NAME="Laravel Bash"
APP_ENV=local
APP_DEBUG=true

DB_CONNECTION=sqlite

QUEUE_WORKER_SLEEP=0.5
QUEUE_JOB_TIMEOUT=60
```

Read a value anywhere with `config`:

```bash
config APP_NAME              # Laravel Bash
config MAIL_MAILER log       # log, the default
```

### Why not `source .env`?

The obvious way to load a `.env` file in Bash is `set -a; source .env; set +a`. That runs your `.env` file as code, so `APP_NAME=$(rm -rf ~)` does exactly what it says. It also overrides real environment variables, which [phpdotenv](https://github.com/vlucas/phpdotenv) doesn't do.

So `env::load` reads the file one line at a time, matches each line against `^([A-Z_][A-Z0-9_]*)=(.*)$`, strips the quotes and comments, and only exports a key if it isn't already set. Real environment variables win, so this works:

```bash
DB_CONNECTION=pgsql ./sail artisan migrate
```

## Databases

SQLite is the default, like Laravel 11 and later. Set `DB_CONNECTION=pgsql` to use the Postgres container that Sail starts. See [Database: Getting Started](/docs/database).

## Next Steps

Read about the [request lifecycle](/docs/lifecycle) to see what actually happens when a browser asks for a page, then [the binaries](/docs/binaries) that make it all work.
