This guide covers how to push changes to Git, run the project on localhost, and deploy to InfinityFree hosting.
- Pushing Changes to Git
- Localhost Setup (XAMPP)
- InfinityFree Deployment
- Configuration
- Troubleshooting
# Navigate to project directory
cd halchash-backend
# Initialize git (if not already initialized)
git init
# Add remote repository (replace with your repo URL)
git remote add origin https://github.com/yourusername/halchash-backend.git
# Add all files
git add .
# Commit changes
git commit -m "Initial commit: Halchash backend setup"
# Push to main branch
git push -u origin main# Check status of changes
git status
# Add specific files or all changes
git add .
# OR add specific files:
# git add index.php config/database.php
# Commit with descriptive message
git commit -m "Fix: Updated admin paths and fixed duplicate code"
# Push to repository
git push origin main
# If working on a feature branch:
git checkout -b feature-name
git add .
git commit -m "Feature: Added new functionality"
git push origin feature-name# View commit history
git log --oneline
# Discard local changes
git checkout -- filename.php
# Pull latest changes from remote
git pull origin main
# Create and switch to new branch
git checkout -b branch-name
# Switch branches
git checkout main- XAMPP installed (includes Apache, MySQL, PHP)
- Git installed
- Code editor (VS Code, PHPStorm, etc.)
- Download and install XAMPP from apachefriends.org
- Start Apache and MySQL from XAMPP Control Panel
# Option A: Clone from Git
cd C:\xampp\htdocs
git clone https://github.com/yourusername/halchash-backend.git
# Option B: Copy project folder
# Copy halchash-backend folder to C:\xampp\htdocs\- Open phpMyAdmin:
http://localhost/phpmyadmin - Create new database:
halchash_db - Import database:
- Click on
halchash_dbdatabase - Go to "Import" tab
- Choose file:
database.sql(from project root) - Click "Go"
- Click on
Edit config/database.php:
// Update these values for your local setup
define('DB_HOST_LOCAL', 'localhost');
define('DB_USER_LOCAL', 'root'); // Default XAMPP username
define('DB_PASS_LOCAL', ''); // Default XAMPP password (empty)
define('DB_NAME_LOCAL', 'halchash_db');# Create uploads directories (if they don't exist)
mkdir uploads\products
mkdir uploads\avatars
# Set permissions (Windows: usually not needed, Linux/Mac: chmod 755)Open your browser and navigate to:
- Main Portal:
http://localhost/halchash-backend/ - Admin Login:
http://localhost/halchash-backend/admin/admin/login.php - Admin Dashboard:
http://localhost/halchash-backend/admin/admin/ - API Endpoint:
http://localhost/halchash-backend/api/products/index.php
- Username:
admin - Password:
admin123
- InfinityFree account (free at infinityfree.net)
- FTP client (FileZilla, WinSCP) or InfinityFree File Manager
- Database credentials from InfinityFree Control Panel
# Make sure all changes are committed
git add .
git commit -m "Ready for deployment"
# Create deployment package (optional - can upload directly)
# Zip the halchash-backend folder (excluding .git, node_modules, etc.)-
Get FTP Credentials:
- Login to InfinityFree Control Panel
- Go to "File Manager" or use FTP
- Note FTP host, username, password
-
Connect via FTP:
Host: ftp.yourdomain.is-great.net Username: u123456789 (from control panel) Password: (from control panel) Port: 21 -
Upload Files:
- Connect to FTP
- Navigate to
htdocsfolder (or root if using subdomain) - Upload all files from
halchash-backendfolder - Important: Upload files directly to root, not in a subfolder
-
Create Database:
- Go to InfinityFree Control Panel
- Click "MySQL Databases"
- Create new database (e.g.,
if0_40378200_halchash_db) - Note the database name, username, password, and host
-
Import Database:
- Go to phpMyAdmin from InfinityFree Control Panel
- Select your database
- Import
database.sqlfile
Edit config/database.php with your InfinityFree credentials:
// Update with your InfinityFree database details
define('DB_HOST_PROD', 'sql311.infinityfree.com'); // Your host
define('DB_USER_PROD', 'if0_40378200'); // Your username
define('DB_PASS_PROD', 'your_password'); // Your password
define('DB_NAME_PROD', 'if0_40378200_halchash_db'); // Your database name
define('DB_PORT_PROD', '3306');Note: The system auto-detects InfinityFree environment, so these values will be used automatically.
Via FTP or File Manager:
uploads/products/β 755 (writable)uploads/avatars/β 755 (writable)- All PHP files β 644
Visit your site:
- Main Portal:
https://halchash.is-great.net/ - Admin Login:
https://halchash.is-great.net/admin/admin/login.php - Admin Dashboard:
https://halchash.is-great.net/admin/admin/
Visit: https://halchash.is-great.net/setup.php
This will verify:
- Database connection
- Required tables exist
- Upload directories are writable
- Default admin account exists
setup.php after setup is complete!
The system automatically detects whether it's running locally or on InfinityFree:
- Local: Detects
localhost,127.0.0.1, or XAMPP paths - Production: Detects InfinityFree domains (
*.is-great.net,*.great-site.net, etc.)
If auto-detection fails, edit config/database.php:
// Force local environment
$forceEnvironment = 'local';
// Force production environment
$forceEnvironment = 'production';Edit config/cors.php to add allowed origins:
$allowed_origins = [
'http://localhost:5173', // Local frontend
'https://halchash.is-great.net', // Production frontend
// Add more origins as needed
];-
Check PHP Errors:
// Add to top of problematic file temporarily error_reporting(E_ALL); ini_set('display_errors', 1);
-
Check Apache Logs:
- XAMPP β Apache β Logs β error.log
-
Verify Database Connection:
- Check
config/database.phpcredentials - Test connection in phpMyAdmin
- Check
-
Check File Paths:
- Ensure you're accessing:
http://localhost/halchash-backend/admin/admin/ - Not:
http://localhost/admin/
- Ensure you're accessing:
- Verify MySQL is running in XAMPP
- Check database name, username, password
- Ensure database exists and is imported
- Check session is starting:
session_start()should be called - Clear browser cookies/cache
- Check database for admin user:
SELECT * FROM admins;
-
Check .htaccess:
- Some directives may not be supported
- Comment out PHP version-specific directives if needed
-
Check File Permissions:
- Files should be 644
- Directories should be 755
-
Check Error Logs:
- InfinityFree Control Panel β Error Logs
- Verify database credentials in
config/database.php - Check database host (usually
sql311.infinityfree.comor similar) - Ensure database exists in InfinityFree Control Panel
- Verify files are uploaded correctly
- Check path:
https://yourdomain.is-great.net/admin/admin/ - Check
.htaccessfile is uploaded
- Update
config/cors.phpwith your frontend URL - Check InfinityFree allows custom headers (some free hosts restrict this)
Access: http://localhost/halchash-backend/admin/admin/debug.php
This shows:
- PHP version
- Database connection status
- Table existence
- File permissions
- Server information
halchash-backend/
βββ admin/
β βββ admin/ # Admin panel files
β βββ index.php # Dashboard
β βββ login.php # Login page
β βββ ...
βββ api/
β βββ api/ # API endpoints
β βββ auth/ # Authentication
β βββ products/ # Products API
β βββ ...
βββ config/
β βββ database.php # Database configuration
β βββ cors.php # CORS settings
β βββ jwt.php # JWT configuration
βββ uploads/ # Uploaded files
β βββ products/ # Product images
β βββ avatars/ # User avatars
βββ index.php # Main entry point
βββ setup.php # Setup script
βββ .htaccess # Apache configuration
βββ README.md # This file
-
Never commit sensitive data:
- Add
config/database.phpto.gitignore(or use environment variables) - Don't commit passwords or API keys
- Add
-
Change default passwords:
- Admin password: Change from
admin123 - Database passwords: Use strong passwords
- Admin password: Change from
-
Delete setup files:
- Remove
setup.phpafter deployment - Remove
debug.phpin production
- Remove
-
File permissions:
- PHP files: 644
- Directories: 755
- Upload directories: 755 (writable)
For issues or questions:
- Check this README
- Review error logs
- Use debug.php for diagnostics
- Check InfinityFree documentation: infinityfree.net/support
- Fixed duplicate code in
index.php - Fixed admin path references
- Added redirect in
admin/index.php - Updated CORS configuration
- Created comprehensive setup guide
Last Updated: 2024