Overview
This guide will walk you through setting up Mis Compras on your local development environment. The platform consists of:- Database Layer: MySQL/MariaDB for data persistence
- Backend: PHP scripts for API endpoints and business logic
- Node.js Backend: Express.js API server (optional modern API layer)
- Frontend: HTML/CSS/JavaScript for the user interface
The platform supports both PHP and Node.js backends. The PHP backend is the primary implementation, while the Node.js backend provides a modern alternative API layer.
Prerequisites
Before you begin, ensure you have the following installed:PHP
Version: 8.0 or higher
mysqliextensionbcryptsupportfileinfoextension (for image uploads)
MySQL/MariaDB
Version: MySQL 8.0+ or MariaDB 10.5+
- Root or administrative access
- Default port: 3306 (or custom port 522)
Node.js (Optional)
Version: 16.x or higher
- npm package manager
- For the Express.js backend
Web Server
Options:
- Apache with mod_php
- XAMPP/WAMP/MAMP
- PHP built-in server
Installation Steps
Clone the Repository
Get the source code for Mis Compras:Your project structure should look like this:
Set Up the Database
Create the Database
Import the provided SQL schema to set up all required tables:- Create a new database named
tienda_online - Import the
tienda_online (1).sqlfile
Database Schema
The import creates the following tables:Core Tables:usuarios- User accounts with hashed passwordsproductos- Product listings with vendor relationshipscategorias- Product categories (Laptops, Smartphones, etc.)pedidos- Customer ordersdetalle_pedido- Order line itemscarrito- Shopping cartsdetalle_carrito- Cart items
Verify Installation
Check that all tables were created:- carrito
- categorias
- detalle_carrito
- detalle_pedido
- pedidos
- productos
- usuarios
Configure File Uploads
Create the directory for product images and set proper permissions:
Image Upload Configuration
The platform stores product images with unique filenames to prevent collisions:Images are named using a timestamp and random hexadecimal string to ensure uniqueness across all uploads.
PHP Configuration
Ensure yourphp.ini allows file uploads:Start the PHP Server
Option 1: PHP Built-in Server (Development)
Navigate to your project directory and start the server:http://localhost:8000Option 2: Apache/XAMPP (Production-like)
-
Copy the project to your web server directory:
- XAMPP:
C:\xampp\htdocs\miscompras\ - MAMP:
/Applications/MAMP/htdocs/miscompras/ - Linux:
/var/www/html/miscompras/
- XAMPP:
- Configure Apache virtual host (optional):
- Add to
/etc/hosts:
- Access at
http://miscompras.local
Start the Node.js Backend (Optional)
If you want to use the modern Express.js API layer:Expected dependencies from The Node.js server will run on API Endpoints:
Install Dependencies
package.json:- express
- cors
- body-parser
- mysql2
- bcrypt
Start the Server
http://localhost:4000 by default.Available Routes
Frombakend/server.js:GET /api/productos- Get all productsPOST /api/usuarios/registro- Register new userPOST /api/pedidos- Create new order
The Node.js backend provides a modern REST API alternative to the PHP endpoints. You can use either or both depending on your needs.
Configuration Options
Database Connection Pooling (Node.js)
The Node.js backend uses connection pooling for better performance:CORS Configuration
Both backends support CORS for cross-origin requests: PHP (in each endpoint):Common Issues and Solutions
Database connection fails with 'Access denied'
Database connection fails with 'Access denied'
Solution: Check your MySQL credentials in
conexion.php or bakend/db.js. Ensure the MySQL user has proper permissions:Image uploads fail with 'Permission denied'
Image uploads fail with 'Permission denied'
Solution: Set proper permissions on the images directory:
PHP displays blank page instead of errors
PHP displays blank page instead of errors
Solution: Enable error display in your PHP configuration:Or add to
php.ini:Node.js backend can't find mysql2 module
Node.js backend can't find mysql2 module
Solution: Install dependencies in the backend directory:
Custom MySQL port (522) not connecting
Custom MySQL port (522) not connecting
Solution: Verify MySQL is running on the custom port:Update both
conexion.php and bakend/db.js with the correct port number.Security Best Practices
Password Hashing
The platform uses secure password hashing: PHP:SQL Injection Prevention
Always use prepared statements:File Upload Validation
Next Steps
Quickstart Guide
Learn how to use the platform - registration, purchases, and listings
API Documentation
Explore all available API endpoints in detail
Database Schema
Understand the complete database structure
Configuration
Configure PHP and Node.js backends
Getting Help
If you encounter issues during installation:- Check the Common Issues section above
- Verify all prerequisites are installed correctly
- Review PHP and MySQL error logs
- Ensure file permissions are set correctly
- Test database connectivity independently