Install PHP and Composer using php.new or your Linux package manager, and run a Laravel app locally.

## WHAT IT IS | The language of your web app.

PHP runs on the server and generates the pages of your website. Laravel, the framework I use to build apps, is written in PHP. You use **Composer** to install a project’s PHP packages.

The easiest way to install everything in one go is to use `php.new`. This is the method recommended by Laravel itself. It installs PHP, Composer and the Laravel installer.

### 01 / Windows

Open PowerShell **as an administrator** (right-click on PowerShell, **Run as administrator**) and run the following:

```
Set-ExecutionPolicy Bypass -Scope Process -Force; [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; iex ((New-Object System.Net.WebClient).DownloadString('https://php.new/install/windows/8.4'))
```

Close PowerShell and open it again.

### 02 / Linux

```
/bin/bash -c "$(curl -fsSL https://php.new/install/linux/8.4)"
```

Close the terminal and open it again.

It’s best to copy the command from laravel.com/docs/installation. That site always lists the latest PHP version.

### 03 / Checking

```
php --version
composer --version
```

## WITHOUT PHP.NEW | Linux packages.

Would you prefer to use Linux’s own package manager? That’s an option too.

### 04 / Ubuntu / Debian / Linux Mint

```
sudo apt update
sudo apt install php-cli php-mbstring php-xml php-curl php-zip php-sqlite3 unzip composer
```

### 05 / Fedora

```
sudo dnf install php-cli php-mbstring php-xml php-pdo composer
```

### 06 / Arch Linux

```
sudo pacman -S php composer
```

Next, use `php --version` to check which version you have. If it’s older than what your project requires, use php.new.

## A PROJECT | Getting started with your Laravel app.

### 07 / Installing packages

Open the terminal in your project folder:

```
composer install
```

Composer creates a `vendor` folder. This should not be included in Git.

### 08 / The configuration file

Copy the example file and create a key:

**Windows**
```
copy .env.example .env
php artisan key:generate
```

**Linux**
```
cp .env.example .env
php artisan key:generate
```

### 09 / Launching the app

```
php artisan serve
```

Open http://127.0.0.1:8000 in your browser. To stop it, press **Ctrl + C**.

Does the project also use Node.js? If so, open a second terminal and run `npm install` and `npm run dev`. See the Node.js and JavaScript manuals.

## WORKING WITH AI | Ask your assistant.

### 10 / A task for your AI assistant

"Check that PHP and Composer are running the versions specified in composer.json, install the packages and run the app locally. Do not carry out any migrations on a database that is not local, and ask for permission before installing anything."

**Good to know**
The `.env` file contains passwords and keys. Never commit it to Git, and do not send it via email or chat. `.env.example` may be committed to Git, provided it does not contain any real data.

