An older single page portfolio built in React, PHP and MySQL. From a time when I was first getting to grips with React, state management libraries and build tools.
- ⚛️ React-based SPA frontend
- 🐘 PHP backend using PDO
- 📦
.envsupport withvlucas/phpdotenv - 🗃️ MySQL for data storage
- 📁 Dynamic project display with images
- 🛠️ Easily deployable with Apache
- Node.js (v18+ recommended)
- Composer (for PHP dependencies)
- PHP 7.4+
- Apache/Nginx (or stack like XAMPP, LAMP, MAMP)
- MySQL or MariaDB
To run this project locally, ensure you have a working PHP + Apache + MySQL stack installed. You can use:
- XAMPP (Windows/Linux/macOS)
- MAMP (macOS/Windows)
- LAMP stack (Linux)
- Native Apache + PHP + MySQL installations
git clone https://github.com/your-username/portfolio.git
cd portfolionpm installcd api
composer install
cd ..Create a .env.production file in the root:
REACT_APP_API_URL=/api
REACT_APP_MEDIA_URL=/media
PUBLIC_URL=/Create a .env file at the root.
DB_HOST=`YOUR_HOST`
DB_NAME=`YOUR_DB_NAME`
DB_USER=`YOUR_USERNAME`
DB_PASSWORD=`YOUR_PASSWORD`Ensure Apache is configured to serve:
- React
build/folder as the main site - PHP
api/folder as the backend
If using XAMPP, place the folder in C:/xampp/htdocs/portfolio.
Then create a Virtual Host (optional):
<VirtualHost *:80>
ServerName portfolio.local
DocumentRoot "C:/xampp/htdocs/portfolio/build"
<Directory "C:/xampp/htdocs/portfolio/build">
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>
</VirtualHost>Update your hosts file:
127.0.0.1 portfolio.local
Restart Apache.
- Start Apache & MySQL via XAMPP/LAMP/MAMP
- For development:
npm run start- For production:
npm run buildThen access via:
http://portfolio.local/
Create a MySQL database named portfolio and import the SQL file to populate project data. You can use phpMyAdmin or CLI.
- React build process removing
public/mediafolder - Static paths not resolving correctly in production
- Integration of PHP API with React in a single project
- Setting up Apache for clean routing and virtual host handling
- Converting CommonJS modules into ES Modules
- Conflicting and Deprecated dependencies (Critical Vunlrabilities)
- Reordered the build script to preserve
media/after React's clean step - Used
PUBLIC_URL=/and proper environment variables - Virtual host configured to serve React
build/while keeping/apiaccessible - PHP
.envhandled viaphpdotenv
Feel free to reach out with questions.