A full-stack restaurant web ordering platform with real-time order tracking, staff management portal, and seamless customer experience. Built with PHP, MySQL, and vanilla JavaScript for optimal performance.
The Regal Elephant is a complete restaurant ordering system designed for dine-in and takeout operations. Customers can browse the menu, place orders, and track their status in real-time using Server-Sent Events (SSE). The integrated staff portal allows restaurant employees to manage incoming orders, update statuses, and configure settingsβall from a secure dashboard.
Why This Exists:
- Streamline restaurant operations without expensive third-party platforms
- Provide customers with instant order feedback and status updates
- Enable staff to efficiently manage orders from a centralized interface
- Maintain full control over customer data and ordering flow
- π Dynamic Menu Display - Browse organized categories (Starters, Main Course, Breads, Desserts & Beverages)
- π Shopping Cart - Add/remove items with quantity management
- π± Responsive Design - Works seamlessly on desktop, tablet, and mobile
- π Real-Time Order Tracking - Live status updates via SSE
- π Order History - View active orders and past purchases
- π° Tip Support - Optional tipping functionality
- π Secure Authentication - Password-protected admin access
- π Order Management - View and update order statuses
- π Real-Time Notifications - Instant alerts for new orders
- βοΈ Settings Panel - Configure restaurant operations
- π Order Details - Full order information with customer details
- Server-Sent Events for real-time updates without WebSocket complexity
- RESTful API architecture for order processing
- Database caching for optimized performance
- Modular PHP structure with clean separation of concerns
| Category | Technology |
|---|---|
| Backend | PHP 7.4+ |
| Database | MySQL 8.0+ |
| Frontend | Vanilla JavaScript (ES6 Modules) |
| CSS Framework | Bootstrap 5.3.5 |
| Icons | Bootstrap Icons |
| Fonts | Google Fonts (Fredoka, League Gothic, Marko One) |
| Real-Time | Server-Sent Events (SSE) |
# Required
PHP >= 7.4
MySQL >= 8.0
Apache/Nginx web server- Clone the repository
git clone https://github.com/AkshayKappala/regal_elephant_web.git
cd regal_elephant_web- Configure the database
Create a MySQL database and import your schema:
mysql -u root -p
CREATE DATABASE regal_elephant;- Update database configuration
Edit config/database.php with your credentials:
<?php
class Database {
private static $connection = null;
public static function getConnection() {
if (self::$connection === null) {
$host = 'localhost';
$username = 'your_username';
$password = 'your_password';
$database = 'regal_elephant';
self:: $connection = new mysqli($host, $username, $password, $database);
if (self::$connection->connect_error) {
die("Connection failed: " . self::$connection->connect_error);
}
}
return self::$connection;
}
}- Configure API settings
Update config/api_config.php with your staff API URL and key:
<?php
define('STAFF_API_URL', 'https://your-staff-api.com/');
define('API_KEY', 'your-secure-api-key-here');- Set up web server
For Apache:
# Point your document root to the project directory
# Ensure mod_rewrite is enabled
sudo a2enmod rewrite
sudo systemctl restart apache2For PHP Built-in Server (Development Only):
php -S localhost:8000- Access the application
- Customer Portal:
http://localhost:8000/ - Staff Portal:
http://localhost:8000/staff/- Default credentials:
admin/elephant2025
- Default credentials:
regal_elephant_web/
βββ api/ # API endpoints
β βββ place_order.php # Order placement (legacy proxy)
β βββ get_order_details.php # Fetch order information
β βββ get_item_ids.php # Retrieve item IDs by name/price
β βββ order_events.php # SSE endpoint for real-time updates
β βββ order_status_events.php # Order status change events
βββ assets/
β βββ css/ # Stylesheets
β βββ src/ # JavaScript modules
β β βββ main.js # Main application entry point
β β βββ cart.js # Shopping cart logic
β β βββ events.js # Event handling
β βββ js/
β βββ staff. js # Staff portal JavaScript
βββ config/
β βββ database.php # Database connection
β βββ api_config.php # API configuration
β βββ get_api_config.php # API config getter
βββ partials/ # Reusable HTML components
βββ staff/ # Staff portal
β βββ index.php # Staff dashboard
β βββ login.php # Staff authentication
β βββ pages/ # Staff portal pages
β βββ assets/ # Staff-specific assets
βββ views/ # Customer-facing pages
β βββ home. php # Landing page
β βββ explore.php # Category exploration
β βββ menu. php # Full menu display
β βββ cart.php # Shopping cart
β βββ orders.php # Order tracking
βββ temp/events/ # SSE event cache (auto-created)
βββ index.php # Application entry point
βββ 404.html # Error page
Update the title in index.php:
<title>Your Restaurant Name</title>And in views/home.php:
<h1 class="display-3 text-center title-home">YOUR RESTAURANT NAME</h1>Edit the category groups in views/menu.php and views/explore.php:
$categoryGroups = [
"Starters" => ["Veg Starter", "Non-Veg Starter"],
"Main Course" => ["Veg Entree", "Non-Veg Entree"],
// Add or remove categories as needed
];Change the default login in staff/index.php:
$validUsername = 'your_username';
$validPassword = 'your_secure_password';Main stylesheet: assets/css/style.css
Example - Change primary color:
:root {
--primary-color: #a04b25; /* Update to your brand color */
--accent-color: #eadab0;
}- Update database credentials in
config/database.php - Set strong staff portal password
- Configure SSL/TLS certificate (HTTPS)
- Set proper file permissions:
chmod 644 *.php - Create
temp/events/directory:mkdir -p temp/events/orders - Set write permissions:
chmod 755 temp/events/ - Disable error display:
ini_set('display_errors', 0); - Enable error logging:
ini_set('log_errors', 1); - Configure API keys in
config/api_config.php - Test SSE functionality across your network
Add to your .htaccess or VirtualHost:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
# Prevent directory browsing
Options -Indexes
# Protect config files
<Files "database.php">
Require all denied
</Files>
<Files "api_config.php">
Require all denied
</Files>
</IfModule>
# Enable SSE
<IfModule mod_headers.c>
Header set X-Accel-Buffering "no"
Header set Cache-Control "no-cache"
</IfModule>For enhanced security, use environment variables for sensitive data:
// In config/database.php
$host = getenv('DB_HOST') ?: 'localhost';
$username = getenv('DB_USER');
$password = getenv('DB_PASS');
$database = getenv('DB_NAME');Problem: Order status changes don't reflect immediately.
Solution:
# Check temp/events directory exists and is writable
mkdir -p temp/events/orders
chmod 755 temp/events
chmod 755 temp/events/orders
# Verify SSE endpoint is accessible
curl http://localhost:8000/api/order_events.phpProblem: Connection failed: Access denied
Solution:
- Verify credentials in
config/database.php - Ensure MySQL is running:
sudo systemctl status mysql - Grant privileges:
GRANT ALL PRIVILEGES ON regal_elephant.* TO 'user'@'localhost';
Problem: Blank page or 500 error.
Solution:
# Check PHP error logs
tail -f /var/log/apache2/error.log
# Verify session directory is writable
ls -la /var/lib/php/sessions/Problem: Cart empties on page refresh.
Solution:
- Check browser localStorage: Open DevTools β Application β Local Storage
- Ensure JavaScript is enabled
- Clear cache and reload
Problem: Real-time updates stop after a few minutes.
Solution:
// Add to api/order_events.php (already implemented)
set_time_limit(0);
ini_set('max_execution_time', 0);
// For Apache, add to .htaccess
<IfModule mod_proxy.c>
ProxyTimeout 600
</IfModule>Developer: Akshay Kappala
GitHub: @AkshayKappala
Repository: regal_elephant_web
Contributions are welcome! Please feel free to submit a Pull Request.
- Fork the repository
- Create your feature branch:
git checkout -b feature/amazing-feature - Commit your changes:
git commit -m 'Add amazing feature' - Push to the branch:
git push origin feature/amazing-feature - Open a Pull Request
This project is open source and available under the MIT License.
Built with β€οΈ for restaurant owners who value independence