# Deployment: schoolmanagement.kanmaadventures.co.ke

This project is a Laravel 12 application. The production environment template is `.env.production.example`; it contains placeholders only and is not a finished server `.env` file.

## 1. Hosting and domain

- Point `schoolmanagement.kanmaadventures.co.ke` to the hosting account and enable an SSL certificate.
- Use PHP 8.2 or newer with the required Laravel extensions, plus MySQL/MariaDB. Enable `pdo_mysql`, `mbstring`, `openssl`, `fileinfo`, `tokenizer`, `xml`, `ctype`, `curl`, and `bcmath` if available.
- Configure the website's document root to this project's `public/` directory. Keep `.env`, `vendor/`, `storage/`, and the rest of the application outside the public web root. Do not make the project root or `.env` web-accessible.
- Create an empty production MySQL/MariaDB database and a restricted database user in the hosting control panel.

## 2. Prepare and upload

1. Build production assets locally with `npm ci` and `npm run build`. Upload the resulting `public/build/` directory; do not upload `node_modules/`.
2. Install production PHP dependencies with `composer install --no-dev --optimize-autoloader`. If Composer is unavailable on the host, run this in a compatible PHP environment locally and upload `vendor/` too.
3. Upload the Laravel application while preserving its directory structure. Do not upload your local `.env` or any local database/password files.
4. On the server, copy `.env.production.example` to `.env`. Fill in the real database and SMTP values. Keep `APP_DEBUG=false` and set `APP_KEY` using `php artisan key:generate` on the server for the first deployment only. Keep that generated key for future deployments; changing it can invalidate encrypted application data and sessions.
5. Ensure the web server can write to `storage/` and `bootstrap/cache/` (commonly directories `775`, subject to the hosting provider's ownership/security guidance).

## 3. Initialize Laravel

Run these commands from the Laravel project root on the server (or use the hosting control panel's terminal):

```sh
php artisan optimize:clear
php artisan migrate --force
php artisan storage:link
php artisan optimize
```

Run database migrations only after confirming the production database is the intended database. If existing school records need to be retained, back up and import the correct database before switching traffic; migrations do not transfer records from the local database.

If shell access is unavailable, ask the hosting provider to run the commands from the project root. The `public/storage` link is required for files saved on the public disk to load in the browser.

## 4. Verify

- Open `https://schoolmanagement.kanmaadventures.co.ke` and confirm the login screen and built CSS/JS load over HTTPS.
- Test login, database-backed pages, and file upload/display.
- Configure valid SMTP credentials before expecting outgoing email to work.
- Check `storage/logs/laravel.log` for startup or permission errors. Never enable `APP_DEBUG` on the public site.

The actual database name, user/password, SMTP host, and credentials depend on the hosting account, so they must be entered privately in the server's `.env`; do not commit or send them in chat.
