teaching_web_development

Installation Guide

This guide will help you set up a local development environment.Below is a clear, step-by-step guide to installing PHP for undergraduate web programming. It covers the three most common platforms and ends with a quick sanity check and common pitfalls.


Installing PHP (for Web Programming)

This guide installs PHP 8.x, suitable for modern web development and coursework.


1. Check if PHP is already installed

Open a terminal (Command Prompt / PowerShell on Windows) and run:

php -v

If you see a version number (e.g. PHP 8.2.x), PHP is already installed. If not, follow the instructions below.


2. Installing PHP on macOS

Best Option

Installing web development tools

To enhance your web development experience, consider installing the following browser extensions:

Miscellaneous

Option B: Homebrew

Most students on macOS should use Homebrew.

Step 1: Install Homebrew (if needed)

/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"

Restart the terminal after installation.

Step 2: Install PHP

brew install php

Step 3: Verify

php -v

You should see something like:

PHP 8.2.x (cli)

Where PHP lives on macOS


3. Installing PHP on Windows

XAMPP bundles PHP + Apache + MySQL, which is ideal for learning.

Step 1: Download XAMPP

Step 2: Install

Step 3: Verify PHP

Open XAMPP Shell or Command Prompt and run:

php -v

If not recognised:


Option C (advanced): PHP only

Download PHP from: https://windows.php.net/download/


4. Installing PHP on Linux (Ubuntu / Debian)

sudo apt update
sudo apt install php php-cli php-common

Optional but useful extensions:

sudo apt install php-curl php-mbstring php-xml php-mysql

Verify:

php -v

5. Running a PHP web server (very important)

PHP includes a built-in development web server.

Step 1: Create a test file

Create index.php:

<?php
echo "Hello, PHP!";

Step 2: Start the server

From the directory containing index.php:

php -S localhost:8000

Step 3: Open browser

Visit:

http://localhost:8000

You should see:

Hello, PHP!

6. PHP vs HTML — how they work together

Example:

<?php
$name = "Student";
?>
<!doctype html>
<html>
<body>
  <h1>Hello <?= $name ?></h1>
</body>
</html>

7. Common problems & fixes

php: command not found

❌ PHP code shows as text in browser

❌ Wrong PHP version


For first-year undergraduates, I recommend:


9. Quick checklist (for a lab handout)