# iRent — cPanel deployment

This package is prepared for a new installation at **https://irent.icoresystems.com**.

## Hosting requirements

- PHP 8.2 or later, with Laravel's standard extensions and PDO MySQL enabled.
- MySQL or MariaDB; the supplied SQL was imported and checked on an isolated MariaDB 10.5 instance.
- HTTPS and a document root pointing to the application's `public` directory.
- PHP write access to `storage` and `bootstrap/cache`.

## New installation

1. Create a new application directory and extract the website ZIP there. The ZIP has application files at its root; avoid extracting it inside an existing application.
2. Create a new empty database and grant a new database user all privileges on that database.
3. In phpMyAdmin, select that empty database and import `database/schema/irent_fresh.sql`.
4. Create `.env` from `.env.example`, then enter the new `DB_DATABASE`, `DB_USERNAME`, and `DB_PASSWORD` values. The package intentionally contains no active `.env` file.
5. Confirm these settings:

```env
APP_NAME="iRent"
APP_ENV=production
APP_DEBUG=false
APP_URL=https://irent.icoresystems.com
APP_TIMEZONE=Africa/Nairobi
SESSION_COOKIE=irent_session
SESSION_ENCRYPT=true
SESSION_SECURE_COOKIE=true
SESSION_DOMAIN=null
CACHE_PREFIX=irent_cache_
```

6. Use PHP 8.2 or later in the application's directory:

```bash
php artisan key:generate --force
php artisan system:create-admin
php artisan storage:link
php artisan config:cache
php artisan route:cache
php artisan view:cache
```

The interactive administrator command creates only the account you enter. On the first account it initializes generic permissions, built-in Admin/Staff roles, and the default chart of accounts so roles and financial posting work on a completely empty import. It does not import customer records, issue invoices, send messages, or create sample accounts.

Do not run `db:seed` to create demo data. The default `DatabaseSeeder` is empty. The imported SQL already contains the complete migration ledger, so there should be no pending migrations immediately after import.

## Data and credentials

All application tables in the supplied SQL are empty. Only the migration ledger contains framework metadata. Primary-key counters start at 1. The schema includes all operational tables from the supplied export, including rent arrears; the old client-specific backup table is excluded.

The release excludes existing `.env` files, application keys, uploaded/private files, logs, cached settings, session files, queued job data, database snapshots, old repair scripts, and old branding assets. The environment template contains blank database and integration secrets.

Set new SMS credentials and an approved sender ID before enabling the SMS module. Set the new M-Pesa paybill, credentials, environment, callback token, and provider URLs before registering callbacks for this installation. Configure SMTP and a verified mail-from address before enabling email delivery. The supplied mail driver writes to the local log.

## Background tasks

After configuration, add cPanel cron jobs using the host's PHP 8.2+ binary and the actual application path:

```cron
* * * * * cd /path/to/irent && php artisan schedule:run >> /dev/null 2>&1
* * * * * cd /path/to/irent && php artisan queue:work --stop-when-empty --tries=3 --timeout=90 >> /dev/null 2>&1
```

## Launch checks

- `https://irent.icoresystems.com/up` returns HTTP 200.
- The login page, dashboard, exports, and statement letterheads show iRent.
- Sign in with the account created during setup.
- Properties, units, tenants, invoices, and payments are empty until you add records.
- Public administrator registration is disabled by default.
- Backups are configured for the new installation.

Local cleanup and import verification do not confirm DNS, hosting, or live deployment. See `cleanup-validation.md` for the exact checks and inherited test failures.

## Later code updates

Keep the server's `.env` and uploaded files during later deployments. Build archives with `scripts/build-cpanel-release.sh`; it excludes local runtime and customer files. Use reviewed migrations for later schema updates. The fresh SQL file is for empty databases and must not be imported over an operational database.
