This project is a fully functional e-commerce website for a bookstore, built with PHP. It provides a complete user experience, from browsing and searching for books to placing orders. It also includes a comprehensive admin panel for site management.
This version has been refactored to run entirely within a Dockerized environment, using MySQL for the database and Apache for the web server.
-
User Facing:
- Browse and search for books.
- View product details.
- User registration and login.
- Add products to a shopping cart.
- Complete checkout process to place an order.
- View order history.
- Submit requests to sell books.
-
Admin Panel:
- View dashboard with site statistics.
- Manage products (add, update, delete).
- Manage placed orders.
- Manage user accounts.
- Review and approve/deny user messages and sell requests.
This project is configured to run seamlessly with Docker and Docker Compose, eliminating the need for a local XAMPP or PHP/MySQL installation.
-
Clone the Repository
git clone <your-repository-url> cd thebooktown_php
-
Set Up Environment Variables
Create a
.envfile by copying the example file:cp .env.example .env
Now, open the
.envfile and fill in the necessary values. For a local setup, you can use the following:MYSQL_ROOT_PASSWORD=rootpassword MYSQL_DATABASE=shop_db MYSQL_USER=user MYSQL_PASSWORD=password SENDGRID_API_KEY=<your_sendgrid_api_key> DB_HOST=db -
Build and Run the Containers
Run the following command from the project root. This will build the PHP/Apache image, install all the necessary Composer dependencies (creating the
vendordirectory inside the image), and start all services in the background.docker-compose up --build -d
The database will be automatically initialized with schema and sample data from the
init.sqlfile the first time you run this command.Note: Because the
vendordirectory is created by Docker, it is included in the.gitignorefile. You can and should delete thevendordirectory from your local machine if it exists. -
Access the Application
- Website: You can now access the bookstore at http://localhost:8080
- Admin Panel: The admin panel is available at http://localhost:8080/admin_login.php
-
Test Credentials
A set of test credentials for both a regular user and an admin are available in the
test_credentials.txtfile.
To stop the containers, run:
docker-compose downTo stop the containers and remove the database volume (useful for a clean restart), run:
docker-compose down -v