Skip to content

Jacques-Overdrive/lamp-stack-test

Repository files navigation

LAMP Stack Test Site

A simple PHP LAMP stack site demonstrating MVC conventions with a lightweight custom router, PSR-4 autoloading, and a PDO database layer.

Stack: PHP 8.2 · MySQL 8.0 · Apache 2.4 · Composer 2.x


Pages

Route Description
/ Welcome / home page
/about About page
/status PHP info, server info, DB connection status, and a live users query

Quick Start

1. Prerequisites

sudo apt install -y apache2 mysql-server php8.2 php8.2-fpm php8.2-cli \
  php8.2-mysql php8.2-mbstring php8.2-xml php8.2-curl php8.2-zip
sudo a2enmod rewrite
composer --version  # Composer 2.x required

2. Clone and install

git clone https://github.com/your-username/lamp-stack-test.git
cd lamp-stack-test
composer install
cp .env.example .env
nano .env  # Fill in DB_DATABASE, DB_USERNAME, DB_PASSWORD

3. Database setup

CREATE DATABASE lamptest_db CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
CREATE USER 'lamptest_user'@'localhost' IDENTIFIED BY 'your_password';
GRANT ALL PRIVILEGES ON lamptest_db.* TO 'lamptest_user'@'localhost';
FLUSH PRIVILEGES;
bash scripts/migrate.sh

4. Apache virtual host

Point DocumentRoot to the public/ directory:

<VirtualHost *:80>
    ServerName lamptest.local
    DocumentRoot /var/www/lamp-stack-test/public

    <Directory /var/www/lamp-stack-test/public>
        AllowOverride All
        Require all granted
    </Directory>
</VirtualHost>
sudo a2ensite lamptest.conf
sudo systemctl reload apache2

5. File permissions

sudo chown -R www-data:www-data storage/ logs/ cache/
sudo chmod -R 755 storage/ logs/ cache/

Project Structure

public/         Apache DocumentRoot — web-accessible only
src/
  Controllers/  Request handlers
  Core/         Router, Database singleton
  Models/       Data access (PDO prepared statements)
  Views/        PHP templates
  Config/       Configuration files
database/
  migrations/   Numbered SQL migration files
tests/          PHPUnit test suites
scripts/        Dev/ops utility scripts

Running Tests

cp .env.example .env.testing
# Set DB_DATABASE=lamptest_test_db in .env.testing
./vendor/bin/phpunit

Coding Standards

PSR-12 · strict types · prepared statements throughout · htmlspecialchars() on all output.

./vendor/bin/phpcs src/

About

Simple PHP LAMP stack test site — MVC, custom router, PDO, PSR-12

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors