Skip to content

Repository files navigation

School Management System — Laravel 12 (Enterprise Edition)

Production-ready, full-stack School Management System built entirely inside Laravel 12.

  • Backend: Laravel 12, Eloquent ORM, MVC, Services, Repositories, Policies, Sanctum
  • Frontend: Laravel Blade + Vite + Vanilla JavaScript + modern CSS3 (futuristic dark glassmorphism UI)
  • Databases: MySQL (primary) + Microsoft SQL Server (secondary, enterprise sync + cross-DB queries)
  • Architecture: Clean MVC + Service/Repository + SOLID + Modular

1. Requirements

Component Version
PHP 8.2+
Composer 2.6+
Node.js 18+
MySQL 8.0+ (or MariaDB 10.6+)
MS SQL Server 2019+ (Express edition works)
PHP extensions pdo_mysql, pdo_sqlsrv, sqlsrv, openssl, mbstring, intl, fileinfo, xml

Recommended local stack: XAMPP + SQL Server Express + Microsoft ODBC Driver 18 + Microsoft Drivers for PHP for SQL Server.


2. Quick Start

# 1) Install dependencies
composer install
npm install

# 2) Configure environment
cp .env.example .env
php artisan key:generate

# Edit .env: set DB_* and SQLSRV_* connection values

# 3) Create databases
#    MySQL:      CREATE DATABASE sms;
#    SQL Server: CREATE DATABASE sms_enterprise;

# 4) Run migrations + seed data
php artisan migrate --seed

# 5) Build assets and run server
npm run dev          # in one terminal (Vite)
php artisan serve    # in another terminal

Open http://localhost:8000. Sign in with:

Role Email Password
Super Admin admin@sms.local password
Admin manager@sms.local password

3. XAMPP Setup

  1. Install XAMPP (PHP 8.2+).
  2. Start Apache + MySQL from the XAMPP control panel.
  3. Open http://localhost/phpmyadmin and create database sms.
  4. Edit php.ini and enable extensions: extension=pdo_mysql, extension=openssl, extension=fileinfo, extension=mbstring, extension=intl.
  5. Restart Apache.

4. SQL Server + PHP Drivers (Windows)

  1. Install SQL Server Express and SQL Server Management Studio (SSMS).
  2. Enable TCP/IP for SQL Server in SQL Server Configuration Manager and restart the SQL Server service.
  3. Install Microsoft ODBC Driver 18 for SQL Server.
  4. Install Microsoft Drivers 5.x for PHP for SQL Server matching your PHP version (TS / x64).
  5. Copy php_sqlsrv_*.dll and php_pdo_sqlsrv_*.dll to your php/ext folder.
  6. In php.ini add:
    extension=sqlsrv
    extension=pdo_sqlsrv
    
  7. Restart Apache and verify with php -m | findstr sqlsrv.
  8. In SSMS create the database: CREATE DATABASE sms_enterprise;.

Test the connection from the app:

GET /api/sqlsrv/test    (requires Sanctum token)

5. Multi-Database Configuration

config/database.php defines two connections:

  • mysql — primary application data (default)
  • sqlsrv — enterprise SQL Server (read-only by default, used for cross-DB queries and sync jobs)

Set credentials in .env:

DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=sms
DB_USERNAME=root
DB_PASSWORD=

SQLSRV_HOST=127.0.0.1
SQLSRV_PORT=1433
SQLSRV_DATABASE=sms_enterprise
SQLSRV_USERNAME=sa
SQLSRV_PASSWORD=password

6. Authentication

  • Session auth for Blade UI (web guard)
  • Laravel Sanctum tokens for the REST API (auth:sanctum)
  • Forgot / reset password flow
  • Rate limiting, CSRF, password hashing (bcrypt)
  • Role + Permission middleware (role:, permission:)
  • Policies for Student, Teacher, Staff, Subject, AcademicYear, Classroom, Section, Exam, User, Role

7. SQL Query Console

Read-only console under /query-console (requires access_query_console permission).

  • Only SELECT (and WITH ... SELECT) statements are allowed
  • Blocked keywords: INSERT, UPDATE, DELETE, DROP, ALTER, CREATE, TRUNCATE, EXEC(UTE), MERGE, GRANT, REVOKE, RENAME, REPLACE, MODIFY
  • Multiple statements (;) blocked
  • Per-query execution time, row count, success/failure logging in query_logs
  • Database selector: MySQL or SQL Server
  • Press Ctrl/Cmd + Enter to run

8. SQL Server Integration APIs

Method Endpoint Description
GET /api/sqlsrv/test Test SQL Server connection
GET /api/sqlsrv/students Read students from sms_enterprise
GET /api/sqlsrv/teachers Read teachers from sms_enterprise
POST /api/sqlsrv/sync Trigger sync job (queued, retries)
GET /api/sqlsrv/logs Last 100 sync runs

Sync is executed via App\Jobs\SyncSqlServerJob. Hooked into the scheduler (php artisan schedule:work) to run hourly.


9. Project Structure

app/
├── Http/
│   ├── Controllers/{Web,Api}/
│   ├── Middleware/{Role,Permission}Middleware.php
│   ├── Requests/
│   └── Resources/
├── Models/
├── Services/
├── Repositories/{Contracts,*Repository}.php
├── Policies/
├── Helpers/
├── Traits/LogsActivity.php
└── Jobs/SyncSqlServerJob.php
resources/
├── views/
│   ├── layouts/{app,sidebar,navbar}.blade.php
│   ├── components/
│   ├── auth/
│   ├── dashboard/
│   └── <module>/{index,create,edit,show}.blade.php
├── css/app.css
└── js/{app,bootstrap}.js
database/
├── migrations/
├── seeders/
└── factories/
routes/
├── web.php
└── api.php

10. Useful Commands

php artisan migrate:fresh --seed          # rebuild DB + demo data
php artisan queue:work                    # process queued jobs (e.g. SQL Server sync)
php artisan schedule:work                 # run scheduled tasks (hourly sync)
php artisan route:list                    # list all routes
php artisan make:filament-resource        # n/a — UI is pure Blade
npm run build                             # production assets

11. Production Deployment Notes

  • Point a vhost at /public
  • APP_ENV=production, APP_DEBUG=false
  • php artisan config:cache route:cache view:cache
  • Run npm run build and commit public/build
  • Set up a daemon to run php artisan queue:work --tries=3 (Supervisor, systemd)
  • Set up cron entry: * * * * * cd /path && php artisan schedule:run >> /dev/null 2>&1
  • Enable HTTPS, configure CSRF / Sanctum stateful domains

12. Security Highlights

  • CSRF on all stateful routes
  • XSS-safe Blade templates ({{ }} escaped)
  • SQL injection prevention via Eloquent + PDO
  • Query Console sanitization (allowlist + statement guard)
  • Rate-limited login (Laravel default throttle)
  • Role + permission middleware
  • Policies for fine-grained model authorization
  • Activity logs (activities) and query logs (query_logs)

Enjoy building 🚀

About

MVC Laravel Project

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages