# Lukenya Premier Academy — Live hosting package

This zip contains the full school ERP application, database dump, and setup scripts.

## Requirements

- PHP 8.1+ with extensions: `pdo_mysql`, `mbstring`, `json`, `fileinfo`
- MySQL 8.0+ or MariaDB 10.4+
- Apache with `mod_rewrite` (or Nginx equivalent)
- Writable folders: `storage/uploads/`, `logs/`

## 1. Upload files

Upload the entire project to your hosting account, for example:

```
/home/username/lukenya-premier/
```

**Document root must point to the `public/` folder**, not the project root.

### Apache example

```apache
DocumentRoot /home/username/lukenya-premier/public
<Directory /home/username/lukenya-premier/public>
    AllowOverride All
    Require all granted
</Directory>
```

### cPanel

Upload the zip, extract it, then set the domain document root to `public`.

## 2. Create database

1. Create a MySQL database and user in your hosting panel.
2. Import the live data:

```bash
mysql -u YOUR_DB_USER -p YOUR_DB_NAME < database/export/live_database.sql
```

Or use phpMyAdmin → Import → `database/export/live_database.sql`.

## 3. Configure the app

Copy `config/config.local.example.php` to `config/config.local.php` and set your live database credentials:

```bash
cp config/config.local.example.php config/config.local.php
```

Or edit `config/config.php` directly (or set environment variables if your host supports them):

| Setting | Live value |
|---------|------------|
| `app.url` | `https://yourdomain.com` (no trailing slash) |
| `app.env` | `production` |
| `app.debug` | `false` |
| `db.host` | Your MySQL host |
| `db.database` | Your database name |
| `db.username` | Your database user |
| `db.password` | Your database password |
| `session.secure` | `true` when using HTTPS |

## 4. Folder permissions

```bash
chmod -R 775 storage/uploads logs
```

Ensure the web server user can write to `storage/uploads/` and `logs/`.

## 5. Verify

1. Run diagnostics (then delete the file):

```
https://yourdomain.com/diag.php?key=lukenya2026
```

To see the exact PHP error on a failing page:

```
https://yourdomain.com/login?deploy_debug=lukenya2026
```

2. Open `https://yourdomain.com` — login page should load with school branding.
2. Sign in as director/admin and confirm learners, fees, and reports load.
3. Test on a phone — bottom navigation and mobile layout should appear.

## Live logins (from current database)

**Staff** — email or staff ID, password from your seeded accounts (change before go-live).

**Parents** — username = child's first name, password = admission number (e.g. `LLA/001`).

Re-run after adding students:

```bash
php database/seed_parent_logins.php
```

## Optional maintenance scripts

Run from the project root via SSH or cron:

```bash
php database/migrate.php
php database/seed_residence_areas.php
php database/assign_student_fees.php
```

## HTTP 500 troubleshooting

| Symptom | Fix |
|---------|-----|
| Login page shows 500 | Upload the latest `core/helpers.php` (fixes `flash()` fatal error on PHP 8) |
| Health check shows database failed | Create DB in cPanel, import `live_database.sql`, set `config/config.local.php` |
| CSS/images broken | App URL auto-detects from the browser; set `app.url` in `config.local.php` if wrong |
| 404 on all routes except index.php | Enable Apache `AllowOverride All` for `.htaccess` rewrite rules |
| PHP version below 8.1 | Switch PHP version in cPanel to **8.1 or 8.2** |

## Security checklist before go-live

- [ ] Change all default staff passwords
- [ ] Set `app.debug` to `false`
- [ ] Use HTTPS and `session.secure = true`
- [ ] Remove or protect `database/` from public web access (only `public/` should be web-visible)
- [ ] Delete `database/export/live_database.sql` from the server after import (contains live data)
