This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
Sploder Revival is a PHP-based web application that powers an online Flash game creation platform. Users can create various types of games (arcade, platformer, shooter, physics puzzles, etc.) and share them with the community.
composer install # Install PHP dependencies
make build # Build the Docker image for development
make dev.bootstrap # Bootstrap database with test data (run once)
make dev.hook # Install pre-commit formatting hooksmake dev # Start development environment (detached)
make dev.watch # Start development environment (attached, see logs)
make dev.down # Stop development environmentDevelopment server runs at: http://127.0.0.1:8010
make test # Run PHPUnit tests (./vendor/bin/phpunit)
./vendor/bin/phpcs # Run PHP CodeSniffer (PSR-12 standard)
./vendor/bin/phpcbf # Auto-fix code style issuesmake dev.bash.db # Access database container
make dev.backup.db # Create schema backup to db/sploder.sqlImportant: After schema changes, always run make dev.backup.db to update the schema dump used for bootstrapping.
make dev.bash.site # Access web application container
make dev.bash.db # Access PostgreSQL containermake build.prod # Build production image
make prod.bootstrap # Bootstrap production database (schema only)
make prod # Start production environment
make prod.down # Stop production environment
make prod.backup.db # Create full database backup
make prod.logs # View production logsProduction server runs at: http://127.0.0.1:8020
The application uses a Repository Pattern with a centralized singleton manager:
-
DatabaseManager (
src/database/databasemanager.php): Manages database connections- PostgreSQL (primary database for all data)
- SQLite (legacy members database for migration)
- Accessed via
DatabaseManager::get()
-
RepositoryManager (
src/repositories/repositorymanager.php): Provides access to all repositories- Singleton pattern:
RepositoryManager::get() - Available repositories:
getGameRepository()- Game data and metadatagetUserRepository()- User accounts and profilesgetGraphicsRepository()- Custom graphics/spritesgetAwardsRepository()- User awards and achievementsgetContestRepository()- Contest informationgetFriendsRepository()- Friend relationshipsgetChallengesRepository()- User challenges
- Singleton pattern:
All repositories implement interfaces (prefixed with I) and accept an IDatabase instance.
src/php/- API endpoints for Flash games (save/load game data, user status, leaderboards)src/repositories/- Database repository layer (interfaces and implementations)src/services/- Business logic services (rendering, game feeds, challenges)src/database/- Database abstraction and connection managementsrc/content/- Shared PHP includes for page components (headers, navigation, initialization)src/make/- Game creation interfaces for different game typessrc/games/- Game playing and browsing pagessrc/accounts/- User authentication and account managementsrc/dashboard/- User dashboard and profile pagessrc/swf/- Flash SWF files for game creators and playerstests/- PHPUnit tests (suffix:*Tests.php)
Environment configuration is managed through .env files:
- Copy
.env.exampletosrc/.envfor manual deployments - Docker deployments use environment variables from docker-compose files
- All configuration is loaded via
src/config/env.php
Key environment variables:
POSTGRES_*- Database connection settingsORIGINAL_MEMBERS_DB- Legacy SQLite database namePHP_ENVIRONMENT-developmentorproduction(affects error handling)SPLODERHEADS_ENABLED- Feature flag for multiplayer gamesSWITCH/SWITCH_TIMER- Maintenance mode killswitch
- Tests are located in
tests/directory - Test files must end with
Tests.php(e.g.,RepositoryManagerTests.php) - Bootstrap:
vendor/autoload.php - Run with:
make testor./vendor/bin/phpunit
- Standard: PSR-12 (enforced via
phpcs.xml) - Pre-commit hook automatically runs
phpcbfto fix formatting issues - Install hook with:
make dev.hook
- Create interface in
src/repositories/i{name}repository.php - Create implementation in
src/repositories/{name}repository.php - Add to
RepositoryManagerclass:- Add private readonly property
- Initialize in constructor
- Add getter method
- Add
require_onceat top of file
Access repositories through the singleton manager:
require_once(__DIR__ . '/repositories/repositorymanager.php');
$repos = RepositoryManager::get();
$gameRepo = $repos->getGameRepository();./vendor/bin/phpunit tests/repositories/RepositoryManagerTests.php- The codebase is maintenance-only - new features are limited, focus is on PHP version compatibility
- Flash Player is required for development (see README.md for compatible browsers)
- Pre-commit hooks ensure code style consistency
- Always update database schema dump after migrations