# Quick Installation Guide

## For Windows (XAMPP)

### 1. Prerequisites Check
```bash
# Check PHP version (must be 8.3+)
php -v

# Check if Composer is installed
composer --version

# Check MySQL is running
# Open XAMPP Control Panel and start MySQL
```

### 2. Install Dependencies
```bash
cd C:\xampp\htdocs\qqr
composer install
```

### 3. Configure Environment
```bash
# Copy environment file
copy .env.example .env

# Edit with Notepad
notepad .env
```

**Minimum .env configuration:**
```env
APP_URL=http://localhost/qqr/public
DB_DATABASE=qr_generator
DB_USERNAME=root
DB_PASSWORD=
```

### 4. Create Database
```bash
# Open MySQL in XAMPP or use command line
mysql -u root -p

# In MySQL console:
CREATE DATABASE qr_generator CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
EXIT;

# Import schema
mysql -u root -p qr_generator < database\schema.sql
```

### 5. Create Storage Folders
```bash
mkdir storage
mkdir storage\qrcodes
mkdir storage\logs
mkdir storage\cache
```

### 6. Access the System
```
URL: http://localhost/qqr/public
Email: admin@company.internal
Password: Admin@123
```

---

## For Linux/Ubuntu

### 1. Install Requirements
```bash
# Update system
sudo apt update

# Install PHP 8.3
sudo apt install php8.3 php8.3-cli php8.3-fpm php8.3-mysql php8.3-mbstring php8.3-xml php8.3-gd

# Install MySQL
sudo apt install mysql-server

# Install Composer
curl -sS https://getcomposer.org/installer | php
sudo mv composer.phar /usr/local/bin/composer
```

### 2. Setup Project
```bash
cd /var/www/html
sudo mkdir qqr
sudo chown $USER:$USER qqr
cd qqr

# Copy your project files here
# Then install dependencies
composer install
```

### 3. Configure Environment
```bash
cp .env.example .env
nano .env
```

### 4. Setup Database
```bash
sudo mysql -u root -p

# In MySQL:
CREATE DATABASE qr_generator CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
CREATE USER 'qr_user'@'localhost' IDENTIFIED BY 'strong_password';
GRANT ALL PRIVILEGES ON qr_generator.* TO 'qr_user'@'localhost';
FLUSH PRIVILEGES;
EXIT;

# Import schema
mysql -u qr_user -p qr_generator < database/schema.sql
```

### 5. Set Permissions
```bash
sudo chown -R www-data:www-data storage
sudo chmod -R 755 storage
sudo chmod -R 755 public
```

### 6. Configure Nginx (if using Nginx)
```bash
sudo nano /etc/nginx/sites-available/qr-generator
```

Add:
```nginx
server {
    listen 80;
    server_name qr.company.local;
    root /var/www/html/qqr/public;

    index index.php;

    location / {
        try_files $uri $uri/ /index.php?$query_string;
    }

    location ~ \.php$ {
        fastcgi_pass unix:/var/run/php/php8.3-fpm.sock;
        fastcgi_index index.php;
        fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
        include fastcgi_params;
    }

    location ~ /\.ht {
        deny all;
    }
}
```

Enable site:
```bash
sudo ln -s /etc/nginx/sites-available/qr-generator /etc/nginx/sites-enabled/
sudo nginx -t
sudo systemctl restart nginx
```

---

## Post-Installation

### 1. Change Default Password
```
1. Login with admin@company.internal / Admin@123
2. Go to Profile
3. Change password immediately
```

### 2. Create Staff Users
```
1. Go to Users menu (Admin only)
2. Click "Create New User"
3. Fill in details and assign role
4. User will receive credentials
```

### 3. Test QR Generation
```
1. Go to QR Codes → Create New
2. Select "Static QR"
3. Enter URL and name
4. Click "Generate QR Code"
5. Download and test scanning
```

### 4. Configure Company Branding
```
Edit .env:
COMPANY_NAME="Your Company Name"
COMPANY_LOGO_URL=/assets/logo.png

Place logo in: public/assets/logo.png
```

---

## Verification Checklist

- [ ] Can access login page
- [ ] Can login with default credentials
- [ ] Dashboard loads correctly
- [ ] Can create static QR code
- [ ] Can download QR code
- [ ] QR code scans correctly
- [ ] Analytics tracking works
- [ ] Can create new user (admin)
- [ ] Logout works

---

## Troubleshooting

**Cannot access the site:**
- Check Apache/Nginx is running
- Verify document root path
- Check .htaccess file exists

**Database errors:**
- Verify MySQL is running
- Check .env database credentials
- Ensure database was imported

**QR codes not generating:**
- Check storage/qrcodes folder exists
- Verify folder permissions
- Check GD extension: `php -m | grep gd`

**Blank page:**
- Enable error display in .env: `APP_DEBUG=true`
- Check PHP error logs
- Verify all dependencies installed

---

## Need Help?

Contact your system administrator or IT department.

For technical issues, check:
- storage/logs/error.log
- Apache/Nginx error logs
- PHP error logs
