# Install Chocolatey if not installed
Set-ExecutionPolicy Bypass -Scope Process -Force; [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; iex ((New-Object System.Net.WebClient).DownloadString('https://community.chocolatey.org/install.ps1'))
# Install PHP
choco install php
# Install Composer
choco install composer
# Verify installations
php -v
composer -v- PHP: https://windows.php.net/download/ (Download PHP 8.x Thread Safe ZIP)
- Composer: https://getcomposer.org/download/
# Using XAMPP (includes PHP, MySQL, Apache)
choco install xampp
# Or standalone MySQL
choco install mysqlcd server-php
composer installThis will install:
firebase/php-jwt- JWT authenticationgoogle/apiclient- Google OAuth verification
Create .env file in server-php directory:
DB_HOST=localhost
DB_PORT=3306
DB_NAME=split_cash
DB_USER=root
DB_PASS=
JWT_SECRET=985e52ac9742bf4c64089fab4b59b1fbbac208300ec827c3f05de6e966285c85ba219339d7e107438536bc4e22713d671c7de22e1e4569cb25c70bd0fefbb7b6
GOOGLE_CLIENT_ID=961328387938-mrob7sroupab8kk14kk1g0io1pa2b5ri.apps.googleusercontent.com
GOOGLE_CLIENT_SECRET=YOUR_GOOGLE_CLIENT_SECRET
EMAIL_HOST=shivarya.dev
EMAIL_PORT=465
EMAIL_USER=[email protected]
EMAIL_PASS=YOUR_EMAIL_PASSWORD
FRONTEND_URL=https://shivarya.github.io/split-cashImport the SQL schema (same as Node.js version):
mysql -u root -p split_cash < database.sqlcd server-php
php -S localhost:3000 index.php- Copy
server-phpfolder toC:\xampp\htdocs\ - Start XAMPP Apache and MySQL
- Access:
http://localhost/server-php/
Similar to XAMPP setup
# Health check
curl http://localhost:3000/health
# Expected response:
# {"success":true,"data":{"status":"healthy","database":"connected","timestamp":"2025-11-25T..."}}# Compress PHP files
Compress-Archive -Path .\server-php\* -DestinationPath server-php.zip- Login to cPanel: https://shivarya.dev:2083
- File Manager β Navigate to
public_html/api/ - Upload
server-php.zip - Extract the ZIP file
- Move contents from
server-phpfolder toapifolder
Final structure:
public_html/
βββ api/
βββ index.php
βββ config/
βββ controllers/
βββ utils/
βββ vendor/
βββ .htaccess
ssh [email protected]
cd public_html/api
composer install# On local machine after composer install
cd server-php
Compress-Archive -Path .\vendor\* -DestinationPath vendor.zip
# Upload vendor.zip to cPanel and extractCreate public_html/api/.htaccess:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /api/
# Handle CORS preflight
RewriteCond %{REQUEST_METHOD} OPTIONS
RewriteRule ^(.*)$ $1 [R=200,L]
# Route all requests to index.php
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php [QSA,L]
</IfModule>
# Enable CORS
Header always set Access-Control-Allow-Origin "*"
Header always set Access-Control-Allow-Methods "GET, POST, PUT, DELETE, OPTIONS"
Header always set Access-Control-Allow-Headers "Content-Type, Authorization"Create public_html/api/.user.ini:
upload_max_filesize = 50M
post_max_size = 50M
memory_limit = 256M
max_execution_time = 300
display_errors = Off
log_errors = On
error_log = /home/username/public_html/api/php_errors.logCreate public_html/api/.env:
DB_HOST=localhost
DB_PORT=3306
DB_NAME=username_split_cash
DB_USER=username_split_cash
DB_PASS=YOUR_DB_PASSWORD
JWT_SECRET=985e52ac9742bf4c64089fab4b59b1fbbac208300ec827c3f05de6e966285c85ba219339d7e107438536bc4e22713d671c7de22e1e4569cb25c70bd0fefbb7b6
GOOGLE_CLIENT_ID=961328387938-mrob7sroupab8kk14kk1g0io1pa2b5ri.apps.googleusercontent.com
GOOGLE_CLIENT_SECRET=YOUR_SECRET
EMAIL_HOST=shivarya.dev
EMAIL_PORT=465
EMAIL_USER=[email protected]
EMAIL_PASS=YOUR_PASSWORD
FRONTEND_URL=https://shivarya.github.io/split-cashLoad .env in config/config.php:
<?php
// Load .env file
$envFile = __DIR__ . '/../.env';
if (file_exists($envFile)) {
$lines = file($envFile, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES);
foreach ($lines as $line) {
if (strpos($line, '=') !== false && strpos($line, '#') !== 0) {
list($name, $value) = explode('=', $line, 2);
$_ENV[trim($name)] = trim($value);
putenv(trim($name) . '=' . trim($value));
}
}
}- cPanel β MySQL Databases
- Create Database:
username_split_cash - Create User:
username_split_cash - Grant All Privileges to user on database
- Import SQL: Use phpMyAdmin to import
database.sql
Update mobile/.env:
API_URL=https://shivarya.dev/api
GOOGLE_CLIENT_ID=961328387938-mrob7sroupab8kk14kk1g0io1pa2b5ri.apps.googleusercontent.comcurl https://shivarya.dev/api/healthAll endpoints remain the same as Node.js version:
POST /api/auth/google- Google OAuth loginGET /api/auth/profile- Get user profilePUT /api/auth/profile- Update user profilePOST /api/groups- Create groupGET /api/groups- Get user's groupsGET /api/groups/:id- Get group detailsPOST /api/expenses/:groupId- Add expenseGET /api/expenses/:groupId- Get group expensesGET /api/balances/:groupId- Get group balancesGET /api/balances/my-balances- Get user's all balances
Enable in php.ini:
extension=mysqli
extension=pdo_mysql
extension=openssl
extension=curl
extension=mbstring
extension=json-
500 Internal Server Error
- Check
php_errors.log - Verify file permissions:
chmod 755on directories,644on files
- Check
-
Database Connection Failed
- Verify database credentials in
.env - Check MySQL is running
- Ensure user has privileges
- Verify database credentials in
-
Composer autoload not found
- Run
composer installin server-php directory - Or upload pre-installed
vendorfolder
- Run
-
.htaccess not working
- Enable mod_rewrite in Apache
- Check AllowOverride is set to All
- PHP 7.4+ installed
- Composer dependencies installed
- MySQL database created and imported
-
.envfile configured -
.htaccesscreated -
/healthendpoint returns success - Google OAuth working
- Mobile app connects to API
API URL: https://shivarya.dev/api
Health Check: https://shivarya.dev/api/health