← Back to Documentation Home

Developer Documentation

For: Developers & System Administrators

This guide covers complete deployment of RMT Attendance System on cPanel shared hosting (like SyokHost) without SSH access.

Note: This guide is specifically for cPanel-based shared hosting where you only have access to File Manager, PHPMyAdmin, and cPanel tools. No terminal/SSH commands required!

System Requirements

Hosting Requirements

Required PHP Extensions

Extension Purpose Required?
BCMath Mathematical operations ✅ Required
Ctype Character type checking ✅ Required
Fileinfo File information detection ✅ Required
JSON JSON data handling ✅ Required
Mbstring Multibyte string support ✅ Required
OpenSSL Encryption and security ✅ Required
PDO Database connectivity ✅ Required
PDO_MySQL MySQL database driver ✅ Required
Tokenizer Code parsing ✅ Required
XML XML processing ✅ Required
GD QR code generation ✅ Required
Curl HTTP requests ✅ Required
Zip Archive handling Recommended

Installation Guide (cPanel)

Step 1: Upload Files to cPanel

1.1 Login to cPanel

1.2 Open File Manager

1.3 Prepare Project Structure

Important: Laravel requires a specific folder structure for security. Follow this exactly!

Create this structure:

public_html/
├── rmt-attendance/          ← All Laravel files EXCEPT public folder
│   ├── app/
│   ├── bootstrap/
│   ├── config/
│   ├── database/
│   ├── resources/
│   ├── routes/
│   ├── storage/
│   ├── vendor/
│   ├── .env
│   ├── artisan
│   └── composer.json
│
└── (public folder contents) ← Contents of 'public' folder go here
    ├── index.php
    ├── .htaccess
    ├── css/
    ├── js/
    └── favicon.ico

1.4 Upload Project Files

  1. Create folder rmt-attendance inside public_html
  2. Zip your project files on your computer
  3. In File Manager, click "Upload"
  4. Upload the ZIP file to public_html/
  5. Right-click the ZIP → "Extract"
  6. Move all files EXCEPT public folder into rmt-attendance/
  7. Move contents of public folder directly to public_html/

Step 2: Setup Database (PHPMyAdmin)

2.1 Create Database

  1. In cPanel, click "MySQL Databases"
  2. Under "Create New Database"
    • Database Name: rmt_attendance
    • Click "Create Database"

2.2 Create Database User

  1. Scroll to "MySQL Users" section
  2. Create new user:
    • Username: rmt_user
    • Password: (create strong password)
    • Click "Create User"

2.3 Add User to Database

  1. Scroll to "Add User To Database"
  2. Select:
    • User: rmt_user
    • Database: rmt_attendance
  3. Click "Add"
  4. On privileges page, check "ALL PRIVILEGES"
  5. Click "Make Changes"
Note: Save your database credentials! You'll need them for the .env file.
  • Database Name: cpanel_rmt_attendance (prefix may be added)
  • Username: cpanel_rmt_user
  • Password: (your password)
  • Host: localhost

Step 3: Configure Environment File

3.1 Rename .env.example

  1. Go to public_html/rmt-attendance/
  2. Find .env.example file
  3. Right-click → "Rename"
  4. Rename to .env (remove .example)

3.2 Edit .env File

  1. Right-click .env → "Edit"
  2. Update these values:
APP_NAME="RMT Attendance"
APP_ENV=production
APP_DEBUG=false
APP_URL=https://yourdomain.com

DB_CONNECTION=mysql
DB_HOST=localhost
DB_PORT=3306
DB_DATABASE=cpanel_rmt_attendance  ← Your database name
DB_USERNAME=cpanel_rmt_user        ← Your database username
DB_PASSWORD=your_password_here     ← Your database password

SESSION_DRIVER=file
CACHE_DRIVER=file
QUEUE_CONNECTION=sync

TIMEZONE=Asia/Kuala_Lumpur
Security Warning:
  • Set APP_DEBUG=false in production!
  • Set APP_ENV=production
  • Keep .env file private (never commit to Git)

3.3 Generate Application Key

You need to generate APP_KEY. Use the helper file:

  1. Navigate to: https://yourdomain.com/generate-key.php
  2. Copy the generated key
  3. Paste in .env file: APP_KEY=base64:xxxxx
  4. Delete generate-key.php after use (security!)

3.4 Update index.php

Edit public_html/index.php:

<?php
// Change from:
require __DIR__.'/../vendor/autoload.php';
$app = require_once __DIR__.'/../bootstrap/app.php';

// To:
require __DIR__.'/rmt-attendance/vendor/autoload.php';
$app = require_once __DIR__.'/rmt-attendance/bootstrap/app.php';
?>

Step 4: Run Database Migrations

No SSH? Use the helper PHP files provided in the public folder!

4.1 Import Database Directly (Option A - Recommended)

  1. In cPanel, open "PHPMyAdmin"
  2. Select your database (e.g., cpanel_rmt_attendance)
  3. Click "Import" tab
  4. Click "Choose File"
  5. Select database.sql from project files
  6. Click "Go"
  7. Wait for import to complete
  8. Verify tables created (should see: users, students, menus, attendance_records, settings)

4.2 Use Helper File (Option B)

  1. Navigate to: https://yourdomain.com/artisan-migrate.php
  2. Click "Run Migration" button
  3. Wait for completion
  4. Check for success message
  5. Delete artisan-migrate.php after use

4.3 Seed Demo Data (Optional)

  1. Navigate to: https://yourdomain.com/artisan-seed.php
  2. Click "Seed Database"
  3. Demo admin account and sample data will be created
  4. Delete artisan-seed.php after use

Laravel needs a symbolic link for file storage:

  1. Navigate to: https://yourdomain.com/create-storage-link.php
  2. Click "Create Storage Link"
  3. Success message should appear
  4. Delete create-storage-link.php after use
Success! If all steps completed, your system is ready!
  • Visit: https://yourdomain.com
  • Login with: admin@rmt.com / admin123
  • Change admin password immediately!

PHP Extensions Configuration

Checking Installed Extensions

  1. Create file phpinfo.php in public_html/:
    <?php
    phpinfo();
    ?>
  2. Visit: https://yourdomain.com/phpinfo.php
  3. Search for required extensions
  4. Delete file after checking!

Enabling Extensions in cPanel

Method 1: MultiPHP Manager (Recommended)

  1. In cPanel, find "MultiPHP Manager"
  2. Select your domain
  3. Click "System PHP Version"
  4. Verify PHP 8.1+ is selected

Method 2: Select PHP Version

  1. In cPanel, find "Select PHP Version"
  2. Choose PHP 8.1 or 8.2
  3. Click "Extensions" tab
  4. Enable required extensions:
    • ☑ bcmath
    • ☑ ctype
    • ☑ fileinfo
    • ☑ json
    • ☑ mbstring
    • ☑ openssl
    • ☑ pdo
    • ☑ pdo_mysql
    • ☑ tokenizer
    • ☑ xml
    • ☑ gd
    • ☑ curl
  5. Click "Save"
GD Extension Critical: Without GD extension, QR codes cannot be generated! Make sure it's enabled.

Helper Files Usage

Since you don't have SSH access, helper PHP files are provided to run Laravel artisan commands via browser.

Available Helper Files

File Purpose URL
create-storage-link.php Create symbolic link for storage /create-storage-link.php
artisan-migrate.php Run database migrations /artisan-migrate.php
artisan-seed.php Seed demo data /artisan-seed.php
artisan-clear.php Clear all cache /artisan-clear.php
generate-key.php Generate APP_KEY /generate-key.php

create-storage-link.php

What it does: Creates symbolic link from public/storage to storage/app/public

When to use: After initial installation, or if QR codes/images not displaying

Usage:

  1. Visit: https://yourdomain.com/create-storage-link.php
  2. Click button or page auto-runs
  3. See success/error message
  4. Delete file after use

artisan-clear.php

What it does: Clears all Laravel cache (config, route, view, application cache)

When to use:

Usage:

  1. Visit: https://yourdomain.com/artisan-clear.php
  2. All caches cleared
  3. Refresh your site
  4. Delete file after use

artisan-migrate.php

What it does: Runs database migrations to create tables

When to use: Initial setup, or when adding new features that need database changes

Usage: Same as above

Security Important: DELETE all helper files after use! They expose system commands and should not be accessible in production.

Subdomain Setup (Optional)

You can run RMT Attendance on a subdomain (e.g., attendance.yourdomain.com)

Create Subdomain in cPanel

  1. In cPanel, find "Subdomains"
  2. Enter subdomain name: attendance
  3. Document Root: public_html/attendance (or custom path)
  4. Click "Create"

Upload Project to Subdomain

  1. Navigate to subdomain folder (e.g., public_html/attendance/)
  2. Follow same upload structure as main installation
  3. Update .env with subdomain URL:
    APP_URL=https://attendance.yourdomain.com

SSL Configuration

Critical for Scanner: HTTPS (SSL) is REQUIRED for camera access! Browsers block camera on non-HTTPS sites.

Free SSL with Let's Encrypt (cPanel)

  1. In cPanel, find "SSL/TLS Status"
  2. Select your domain
  3. Click "Run AutoSSL"
  4. Wait for certificate to be issued (few minutes)
  5. Verify SSL active (padlock icon in browser)

Force HTTPS (Redirect HTTP to HTTPS)

Edit .htaccess in public_html/:

# Add at the top, before other rules
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

# Existing Laravel rules below...

This ensures all visitors use HTTPS.

PHPMyAdmin Guide

Accessing PHPMyAdmin

  1. In cPanel, click "PHPMyAdmin"
  2. Database opens automatically
  3. Select your database from left sidebar

Common Tasks

Import Database

  1. Click "Import" tab
  2. Choose database.sql file
  3. Click "Go"

Export Database (Backup)

  1. Click "Export" tab
  2. Select "Quick" method
  3. Format: SQL
  4. Click "Go"
  5. Save file to your computer

View Tables

Run SQL Queries

  1. Click "SQL" tab
  2. Enter SQL query
  3. Click "Go"

Example - Reset Admin Password:

UPDATE users
SET password = '$2y$10$92IXUNpkjO0rOQ5byMi.Ye4oKoEa3Ro9llC/.og/at2.uheWG/igi'
WHERE email = 'admin@rmt.com';

-- Password will be: password

File Permissions

Required Permissions

Folder/File Permission Recursive?
storage/ 755 ✅ Yes
bootstrap/cache/ 755 ✅ Yes
.env 644 ❌ No
All other files 644 ❌ No
All other folders 755 ✅ Yes

Setting Permissions in cPanel

  1. Open File Manager
  2. Navigate to folder (e.g., rmt-attendance/storage/)
  3. Right-click folder → "Change Permissions"
  4. Check boxes to set 755:
    • Owner: Read, Write, Execute (7)
    • Group: Read, Execute (5)
    • World: Read, Execute (5)
  5. Check "Recurse into subdirectories"
  6. Click "Change Permissions"
Permission Errors? If you see "Permission denied" errors, check storage and bootstrap/cache folders first.

Troubleshooting

Issue 1: White Screen / 500 Error

Causes:

Solutions:

  1. Check index.php paths are correct
  2. Verify .env exists in rmt-attendance/ folder
  3. Generate APP_KEY using generate-key.php
  4. Set storage/ to 755 permissions
  5. Check error log: cPanel → "Errors" or storage/logs/laravel.log

Issue 2: Database Connection Error

Error: "SQLSTATE[HY000] [1049] Unknown database"

Solutions:

  1. Verify database exists in PHPMyAdmin
  2. Check .env database credentials:
    • DB_DATABASE (include cPanel prefix if any)
    • DB_USERNAME (include cPanel prefix)
    • DB_PASSWORD (correct password)
  3. Verify user has privileges on database
  4. Clear cache: artisan-clear.php

Issue 3: QR Codes Not Generating

Causes:

Solutions:

  1. Enable GD extension in "Select PHP Version"
  2. Run create-storage-link.php
  3. Set storage/app/public/ to 755 permissions
  4. Check phpinfo.php - search for "gd"

Issue 4: Camera Not Working in Scanner

Causes:

Solutions:

  1. Install SSL certificate (Let's Encrypt)
  2. Force HTTPS redirect in .htaccess
  3. Check browser allows camera (Chrome, Firefox, Edge)
  4. Grant camera permission when prompted

Issue 5: Excel Import/Export Not Working

Causes:

Solutions:

  1. Verify vendor/ folder uploaded completely
  2. Increase PHP limits in cPanel → "Select PHP Version" → "Options":
    • memory_limit: 512M
    • max_execution_time: 300
    • upload_max_filesize: 10M

Issue 6: Changes Not Reflecting

Solution: Clear all cache using artisan-clear.php

Getting Detailed Error Messages

Temporarily enable debug mode:

  1. Edit .env
  2. Change APP_DEBUG=false to APP_DEBUG=true
  3. Reproduce the error
  4. Read detailed error message
  5. IMPORTANT: Set back to false after debugging!
Never leave debug mode on in production! It exposes sensitive information.

Check Error Logs

Laravel Log:

Server Error Log:

Still Having Issues?

Contact support with:

Pro Tip: Before asking for help, try:
  1. Clear cache (artisan-clear.php)
  2. Check file permissions
  3. Verify .env configuration
  4. Check error logs


← Back to Documentation Home