- 1 Projects
- 2 Details
- 3 Code on GitHub
Open source | PHP and MySQL | Runs in Docker
Cab Booking System
A cab booking and fleet management web app in PHP 8 and MySQL, built for the DBMS course at IIIT Delhi. Customers book a free cab and follow its status, drivers move each job through its stages, and staff run the fleet. The whole stack starts with one Docker command.
- PHP 8
- MySQL
- AdminLTE 3
- jQuery
- Docker
- GitHub Actions
- 4
- roles: customer, driver, staff and admin
- 5
- booking states, from pending to dropped off
- 6
- tables in the MySQL schema
- 3
- PHP versions linted in CI
Overview
What it does
Customers register, find a cab that is free, book it and follow the booking through Pending, Driver Confirmed, Picked-up and Dropped off. They can cancel while it is still pending. Drivers sign in as their cab and move each job forward. Staff manage categories, cabs, drivers and customers, including blocking an account, and administrators also manage staff accounts and site settings.
It is plain PHP with AdminLTE 3 and jQuery on the front end: no framework and no build step. docker compose up starts PHP 8.2 with Apache next to MySQL, and the schema and seed data load on first boot.
- Type
- Server-rendered web app
- Stack
- PHP 8, MySQL, AdminLTE 3, jQuery
- Runs on
- php:8.2-apache and MySQL via Docker Compose
- Schema
- 6 tables with seed data
- Code
- 66 PHP files
- CI
- GitHub Actions: lint, then a Docker smoke test
How it works
A booking, end to end
Route the request
Every customer page goes through
index.php. It loads the configuration, which reads the environment, starts the session and opens the database connection, then passes the page name throughsafe_page_name(). Only letters, digits, dashes, underscores and slashes get through, and anything else falls back to the home page.index.php, config.php, initialize.php
List the free cabs
The available-cabs page shows every cab that has no booking in an active state.
cab_available.php
Book
A signed-in customer picks a cab and the booking form opens in a modal for pickup and drop-off. Anyone who is not signed in is sent to the sign-in page first.
booking.php
Save the booking
The form goes by AJAX to
Master::save_booking(), which attaches the customer from the session and a reference code in the form YYYYMM-NNNNN, then answers with JSON.classes/Master.php
Follow the status
The customer's booking list is a bound query on their id, and a single booking is shown only to the people whose role lets them see it.
booking_list.php, view_booking.php
The driver moves it forward
The driver signs in as the cab and steps the job through confirmed, picked up and dropped off. Each step is a bound UPDATE in
update_booking_status().driver/, classes/Master.php
Accounts
Signing in, and upgrading old passwords on the way
There are three sign-in pages: customers use their email at /, staff a username at /admin, and drivers their cab registration code at /driver. All three end up in the same class.
Look up the account
A bound
fetchOne()on the customer, staff or cab table.classes/Login.php
Check the password
Password::verify()usespassword_verify()for bcrypt. A stored value of 32 hex characters is treated as a legacy MD5 hash and compared withhash_equals().classes/Password.php
Refuse blocked accounts
Customers and drivers who have been blocked are turned away at this point.
Upgrade the hash
If the stored hash is MD5, or bcrypt at an old cost,
upgradeHash()writes a fresh bcrypt hash at cost 12 through a bound UPDATE. Old accounts move to bcrypt the next time they sign in, and nobody is locked out.Login::upgradeHash()
Start the session
session_regenerate_id(true)issues a new session id, the account row goes into the session without its password, and the browser is sent to the right area.
Engineering decisions
Hardening in place
One prepared-statement helper
DBConnection::run() is the single place that calls prepare(). It works out an i, d or s type for each value and binds it. Helpers such as fetchOne() wrap it, buildSet() only accepts whitelisted column names, and inList() keeps only numeric ids. Sign-in, booking lookups and status changes all run through it.
bcrypt with an in-place upgrade
New passwords are hashed with bcrypt at cost 12. Legacy MD5 hashes still verify, once, and are replaced on that sign-in. The seed script writes bcrypt, so a fresh install starts with no MD5 at all.
A router that only includes known pages
Page names must match ^[A-Za-z0-9_-]+(?:/[A-Za-z0-9_-]+)*$. Anything else becomes the home page, and a name that matches no file gets 404.html.
Secrets and internals out of reach
.env is git-ignored and never overrides a real environment variable. .htaccess returns 403 for the database and docker folders, .git, dotfiles and .env, .sql and .yml files, and sets nosniff, SAMEORIGIN and Referrer-Policy headers. Session cookies are HttpOnly and SameSite=Lax, and Secure over HTTPS.
CI
How it is checked
.github/workflows/ci.yml runs on every push to main and on pull requests. The lint job runs php -l over all 66 PHP files on PHP 8.0, 8.2 and 8.3. The smoke job then boots the real stack with Docker Compose and checks it from the outside:
- the home page renders
- the seeded admin can sign in
- a wrong password is refused, and the response leaks no SQL
- an account holding an MD5 hash signs in and comes back out of the database as bcrypt
.env, the schema dump anddocker-compose.ymlare not served- a path-traversal page name does not expose the configuration
Run it yourself
git clone https://github.com/vipul21435/CabBooking-PHP.git
cd CabBooking-PHP
cp .env.example .env
docker compose up
# open http://localhost:8000
Demo accounts
The seed data includes an administrator and a staff user at /admin, a customer at / and a driver at /driver. The README lists their demo passwords and says to change them before any real use.
Step 3 of 3
The code
The PHP, the schema and seed data, the Docker setup and the CI workflow are all in the repository.
github.com/vipul21435/CabBooking-PHP