Prerequisites
Before setting up MinistryHub locally, ensure you have the following installed:- Node.js 18.x or higher
- PHP 8.0 or higher
- MySQL 8.0 or higher
- A local web server (Apache, Nginx, or PHP’s built-in server)
- Package manager: npm, yarn, or pnpm
Project Structure
MinistryHub uses a secure architecture that separates public and private code:Clone the Repository
First, clone the MinistryHub repository:Database Setup
MinistryHub uses two separate databases for better organization:1. Create Databases
Create two MySQL databases:2. Import SQL Files
Import the schema files located in your project:3. Configure Database Connection
Create the configuration file atbackend/config/database.env:
backend/config/database.env
Backend Setup
The backend uses vanilla PHP with PSR-4 autoloading and requires no additional dependencies.1. Verify PHP Configuration
Ensure PHP has the required extensions:2. Create Logs Directory
Ensure the logs directory exists and is writable:3. Start PHP Development Server
You can use PHP’s built-in server for local development:The
.htaccess file handles routing for both API calls (/api/*) and SPA routes. All API requests are routed to api/index.php.Frontend Setup
The frontend is built with React 19, TypeScript, and Vite.1. Navigate to Frontend Directory
2. Install Dependencies
3. Configure Environment Variables
Create a.env file in the frontend directory:
frontend/.env
The frontend uses a relative API URL (
/api) which works seamlessly in development when both frontend and backend are served from the same origin.4. Start Development Server
http://localhost:5173 by default.
Development Workflow
Hot Module Replacement
Vite provides instant hot module replacement (HMR) for React components. Your changes will appear immediately without a full page reload.API Development
When making changes to the backend:- Edit PHP files in
backend/src/ - No build step required - changes are reflected immediately
- Check
backend/logs/for error logs if needed
Frontend Development
When working on the React frontend:- Edit files in
frontend/src/ - Vite automatically recompiles and hot-reloads
- Use the browser console for debugging
Request Lifecycle
Understanding how requests flow through the system:- Client Request: Browser visits
localhost:5173/worship/songs .htaccessIntervention:- If it’s an
/api/*call → routes toapi/index.php - If it’s a page route → serves
index.html(React Router takes over)
- If it’s an
- API Handling:
api/index.phpextracts JWT, identifies user, routes to Controller - Data Layer: Controller asks Repository for data using PDO
Development Tools
DevProfileSelector
In development mode, MinistryHub includes a profile selector for testing:import.meta.env.DEV is true.
TypeScript
Run TypeScript type checking:Linting
Run ESLint to check code quality:Troubleshooting
Database Connection Issues
Error: Database configuration missing
Error: Database configuration missing
Ensure
backend/config/database.env exists and contains all required variables:DB_HOST,DB_USER,DB_PASS,DB_NAMEMUSIC_DB_HOST,MUSIC_DB_USER,MUSIC_DB_PASS,MUSIC_DB_NAME
PDO Connection Failed
PDO Connection Failed
Verify your MySQL service is running:
Character Set Issues
Character Set Issues
Ensure your databases use UTF-8:
Frontend Issues
API Requests Failing (CORS)
API Requests Failing (CORS)
If you’re running frontend and backend on different ports, you may encounter CORS issues. The backend initializes CORS in Check your CORS configuration in the Cors helper.
backend/src/bootstrap.php:Vite Build Errors
Vite Build Errors
Clear Vite cache and reinstall dependencies:
TypeScript Errors
TypeScript Errors
Run type checking to see detailed errors:
PHP Issues
Authorization Header Not Visible
Authorization Header Not Visible
404 on API Routes
404 on API Routes
Ensure
mod_rewrite is enabled in Apache:Next Steps
Configuration
Learn about advanced configuration options
Production
Deploy MinistryHub to production