Star Wars Unlimited Sim
If you need to contact us or would like to get involved in the dev work, please reach out in our Discord server!
We have two options for setting up a development environment: a docker-based method that is fully automatic and supports live debug, or a walkthrough for how to set up the environment manually on your local machine.
We provide a docker environment for local run with built-in xdebug support for live debugging, which can be installed and started in two commands if you already have docker set up. A preconfigured setup is provided for Visual Studio Code (it would be very simple to set up other tools as well).
If you are on Windows, please follow the instructions for installing Docker Desktop on Windows (either WSL or Hyper-V backend should work but we have only tested with WSL): https://docs.docker.com/desktop/install/windows-install/
Run the following commands to start / stop the service
bash petranaki.sh start
bash petranaki.sh stop
bash petranaki.sh restartOpen this address in your browser: http://localhost:8080/Arena/MainMenu.php
If you want to play a game against yourself, open multiple windows / tabs and connect.
Xdebug is already running in the service, you can use these steps to do live debugging with breakpoints in Visual Studio Code:
- Install an extension that supports PHP debugging, such as https://marketplace.visualstudio.com/items?itemName=DEVSENSE.phptools-vscode
- We have a preconfigured launch.json to enable the debug action. In the vscode debug window (Ctrl + Shift + D), select the configuration
SWUOnline: Listen for Xdebugand hit the Run button. - You are now connected for debugging, add a breakpoint and try it out :)
Additionally, any tool that can connect to xdebug remotely should work as well.
We have a Google Doc with instructions for setting up the environment. Some steps may be missing or require extra detail, if you find any issues please contact us via the Discord so we can improve the document.
https://docs.google.com/document/d/10u3qGpxr1ddvwobq8__lVZfYCgqtanZShHEaYljiA1M/edit?usp=sharing
This guide explains how to set up CI/CD, including deploying with GitHub, securing webhooks, and configuring environment variables.
-
Generate a secret key to secure the webhook:
openssl rand -hex 32
Save this secret for later use.
-
In your GitHub repository, go to Settings > Webhooks and create a new webhook with the following settings:
- Payload URL:
https://petranaki.net/Arena/Webhook.php - Content Type:
application/json - Secret:
<webhook-secret>(use the secret generated earlier) - SSL Verification: Enabled
- Events: Select "Just the push event" to trigger the webhook on push events.
- Payload URL:
To secure your project and set environment variables:
- Navigate to your project directory:
/var/www/html/petranaki - Create or edit an
.htaccessfile with the following content:RedirectMatch 404 /\.git SetEnv MYSQL_SERVER_NAME localhost SetEnv MYSQL_SERVER_USER_NAME root SetEnv MYSQL_ROOT_PASSWORD <mysql-password> (password for the custom user) SetEnv WEBHOOK_SECRET <webhook-secret> SetEnv PATREON_CLIENT_ID <patreon-client-id> SetEnv PATREON_CLIENT_SECRET <patreon-client-secret> RewriteEngine On # Redirect from / to /Arena/MainMenu.php RewriteRule ^$ /Arena/MainMenu.php [L,R=301] # Redirect from /Arena to /Arena/MainMenu.php RewriteRule ^Arena/?$ /Arena/MainMenu.php [L,R=301]
This configuration ensures that the .git folder is inaccessible and adds environment variables for your project.
If your project is not yet synced to GitHub, follow these steps:
-
Initialize the project as a Git repository:
git init
-
Fetch the project from GitHub:
git fetch https://github.com/SWU-Petranaki/SWUOnline.git main
-
Reset the project to the latest version:
git reset --hard FETCH_HEAD
Note: Files listed in
.gitignorewill remain unaffected. Back up important files before running this command to avoid accidental data loss. -
Pull the latest changes from GitHub:
git pull https://github.com/SWU-Petranaki/SWUOnline.git main
-
Grant permissions to the
daemonuser:sudo chown -R daemon:daemon /opt/lampp/htdocs/petranaki/Arena
-
Add the project directory to the safe directory list:
sudo git config --system --add safe.directory /opt/lampp/htdocs/petranaki/Arena
-
Test the setup:
sudo -u daemon git pull https://github.com/SWU-Petranaki/SWUOnline.git main
The Webhook.php script will execute using the daemon user, so it must have permissions to run git pull.
-
Edit the sudoers file:
sudo visudo
-
Add the following line to grant limited permissions:
daemon ALL=(ALL) NOPASSWD: /usr/bin/git
This ensures that the daemon user can authenticate with GitHub when the webhook triggers a git pull operation.
Your project is now configured for CI/CD. Any commit pushed to the main branch will trigger the webhook, which executes a git pull on the server to update the project files automatically.