{"id":13670637,"url":"https://github.com/smrealms/smr","last_synced_at":"2025-04-27T13:32:46.731Z","repository":{"id":3687155,"uuid":"4757357","full_name":"smrealms/smr","owner":"smrealms","description":"Space Merchant Realms open-source game engine","archived":false,"fork":false,"pushed_at":"2025-04-26T20:49:04.000Z","size":25473,"stargazers_count":26,"open_issues_count":26,"forks_count":16,"subscribers_count":8,"default_branch":"main","last_synced_at":"2025-04-26T21:27:34.623Z","etag":null,"topics":["docker","foss","mmo","mysql","pbbg","php8","space-game"],"latest_commit_sha":null,"homepage":"http://www.smrealms.de","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"agpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/smrealms.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2012-06-23T00:22:22.000Z","updated_at":"2025-04-26T20:49:06.000Z","dependencies_parsed_at":"2023-07-06T13:31:41.086Z","dependency_job_id":"f7656851-83f1-4647-8114-a061d397d07a","html_url":"https://github.com/smrealms/smr","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/smrealms%2Fsmr","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/smrealms%2Fsmr/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/smrealms%2Fsmr/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/smrealms%2Fsmr/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/smrealms","download_url":"https://codeload.github.com/smrealms/smr/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251145668,"owners_count":21543079,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["docker","foss","mmo","mysql","pbbg","php8","space-game"],"created_at":"2024-08-02T09:00:46.828Z","updated_at":"2025-04-27T13:32:41.720Z","avatar_url":"https://github.com/smrealms.png","language":"PHP","funding_links":[],"categories":["Uncategorized"],"sub_categories":["Uncategorized"],"readme":"[![Run Tests](https://github.com/smrealms/smr/actions/workflows/run-tests.yml/badge.svg?branch=main)](https://github.com/smrealms/smr/actions/workflows/run-tests.yml?query=branch%3Amain)\n[![Test Coverage](https://codecov.io/gh/smrealms/smr/branch/main/graph/badge.svg)](https://codecov.io/gh/smrealms/smr)\n[![PHPStan Level](https://img.shields.io/badge/PHPStan-level%208-brightgreen.svg)](https://github.com/smrealms/smr/blob/main/phpstan.neon.dist)\n[![Build Live](https://github.com/smrealms/smr/actions/workflows/build-live.yml/badge.svg?branch=live)](https://hub.docker.com/repository/docker/smrealms/smr)\n\n# Installation\n\n## Dependencies\nMake sure the following software is installed:\n* docker (version 19.03.0+)\n* docker compose plugin (v2)\n\nTo run unit tests on your machine:\n* Composer (2.0.5+)\n\n## Setup\nFirst, you will need to clone this repository. Then inside the clone, you\nwill need to create installation-specific copies of the following files:\n\n* `.env.sample` \u0026rarr; `.env`\n* `config/config.specific.sample.php` \u0026rarr; `config/config.specific.php`\n\nThe sample versions have sensible defaults, but update the copies as necessary.\nThe options must be consistent between the various configuration files.\n\n## Populate the mysql database\nTo initialize the database or update it with new patches, run:\n```\ndocker compose run --rm flyway\n```\n\nTo modify the database, add a file called `V\u003cVERSION_NUMBER\u003e__\u003cNAME\u003e.sql` into\n`db/patches` and rerun the command.\n\nYou can optionally start up [phpMyAdmin](https://www.phpmyadmin.net/) to\ninspect your mysql database in a web browser at `http://localhost/pma/`:\n```\ndocker compose up --build -d pma\n```\n\n## Start up the services\nThen you can start up the persistent game services\n```\ndocker compose up --build -d traefik smr\n```\n\nFor development, it may be desirable to automatically pick up source code changes without rebuilding the docker image. Simply use the `smr-dev` service instead of `smr`, i.e.:\n```\ndocker compose up --build -d traefik smr-dev\n```\n\n\n# Runtime\n\n## Permissions\nIn order to create an admin account you should first create a standard account\nvia the register form, then run the following command to give that account\nadmin permissions:\n\n```bash\ndb/init_admin.sh\n```\n\nThe account should now have an \"Admin Tools\" link on the left whilst logged in,\nwhich will allow you to assign any extra permissions to yourself and others.\n\n## Creating a Game\nTo create a game you will have to have assigned yourself the \"1.6 Universe Generator\" and then access this link via the admin tools to create the game.\nOnce you are happy with the game you need to edit the \"game\" table and set the \"enabled\" flag for your game to 'TRUE' in order for it to appear in the list of games to join.\n\n# Coding Style\nThis is the coding style that should be used for any new code, although currently not all code currently follows these guidelines (the guidelines are also likely to require extension).\n\n* Opening races should be placed on the same line with a single space before\n* Single line if statements should still include braces\n\n\t```php\n\tif (true) {\n\t}\n\t```\n\n* Variable names should be camelCase normally, except when in templates when they should be UpperCamelCase (to enforce some mental separation between the two contexts).\n\n\t```php\n\t$applicationVar = 'value';\n\t$TemplateVar = 'value';\n\t```\n\n* Function names should be camelCase, class names should be UpperCamelCase\n\n\t```php\n\tfunction exampleFunction() {\n\n\t}\n\n\tclass ExampleClass {\n\t\tpublic function exampleMethod() {\n\t\t}\n\t}\n\t```\n\n* Associative array indices should be UpperCamelCase\n\n\t```php\n\t$container['SectorID'] = $sectorID;\n\t```\n\n# SMR-isms\n## File inclusion\nClasses should be added to `src/lib/Smr` to take advantage of the PSR-4 autoloader.\nEngine files and their associated templates should be placed in `src/engine` and\n`src/templates` respectively (see `Page::process` for how they will be included).\n\n## Links\nIf possible use a function from `Globals` or a relevant object to generate links (e.g. `Globals::getCurrentSectorHREF()` or `$otherPlayer-\u003egetExamineTraderHREF()`).\nThis is usually clearer and allows hooking into the hotkey system.\nTo create a link you first create a \"container\" using a `Page` class, e.g.:\n\n```php\n$container = new CurrentSector();\n```\nYou can then call `$container-\u003ehref()` to get a HREF, which will give a link that\ncan be displayed on the page. In this example, clicking the link will load the\n\"Current Sector\" page next.\n\nYou can also call `$container-\u003ego()`, which will immediately forward to this page\nwithin the same HTTP request.\n\n## Request variables\nFor any page which takes input through POST or GET, these values may be accessed\nusing `Smr\\Session::getRequestVar()` and relatives, which will store the value\nin the session. When a page is auto-refreshed with AJAX, these inputs are not\nresent, but they are still required to render the page correctly.\n\n## Abstract vs normal classes\nThis initially started out to be used in the \"standard\" way for NPCs but that idea has since been discarded.\nNow all core/shared \"Default\" code should be in the abstract version, with the normal class child implementing game type specific functionality/overrides, for instance \"lib/Semi Wars/Account\" which is used to make every account appear to be a \"vet\" account when playing semi wars.\n\n## Unit testing\nSMR uses [PHPUnit](https://phpunit.de/) to run unit tests.\n### Setup\n1. Ensure the MySQL container is running, and ready for any integration tests that touch the database:\n   * `composer start:test-services`\n1. Run `composer phpunit` to execute the full suite of PHPUnit tests.\n1. Add new tests as needed in the `/test` directory.\n\n### Setting up your IDE to run tests\nThis information applies to IDEA-based IDEs, e.g. `IntelliJ`, `PHPStorm`. For other vendors, please refer to your vendor's documentation for running PHPUnit tests against a remote container.\n* In order to perform these next steps in `IntelliJ`, you must have the following Jetbrains-provided plugins installed:\n * [PHP](https://plugins.jetbrains.com/plugin/6610-php)\n * [PHP Docker](https://plugins.jetbrains.com/plugin/8595-php-docker)\n   * This should also install [PHP Remote Intepreter](https://plugins.jetbrains.com/plugin/7511-php-remote-interpreter)\n\n##### Configure a remote PHP interpreter for the project\n\n1. `File \u003e Settings \u003e Languages \u0026 Frameworks \u003e PHP`. In the `CLI Interpreter` area, click the `...` button\n1. Press the \"+\" button in the top left, and select `From Docker, Vagrant, VM, WSL, Remote...`\n1. In the new window, choose `Docker Compose`, and in the `Service` area, select `phpunit`. Press \"OK\".\n1. It will check the configuration by starting up the Docker container, and gathering PHP information. Once that's finished, you should be on a configuration screen for the new interpreter. It should have the PHP information from the Docker container, and also the `Xdebug` information.\n1. In the `Environment variables` box on the new intepreter's screen, paste in the values from `/test/env` in the project directory.\n1. The rest of the default settings should be fine, so you can press \"Apply\".\n1. On the settings navigation tree, underneath PHP, click the `Composer` item: In the `CLI Interpreter` drop down, select the new interpreter you've created. Press \"Apply\".\n1. On the settings navigation tree, underneath PHP, click the `Test Frameworks` item.\n1. Click the `+` button to create an entry, select the newly created interpreter from the drop down, and press \"OK\".\n1. In the `PHPUnit library` section, set the `Path to script` value to `/smr/vendor/autoload.php`\n1. In the `Test Runner` section, set the `Default configuration file` to `/smr/phpunit.xml`\n1. Press \"OK\", and you should be good to go for executing tests inside the IDE.\n\n### Writing integration tests\n1. To create an integration test that uses the database, your test should extend `SmrTest\\BaseIntegrationSpec`. This will ensure that any test data that gets written to the database will be cleaned up after each test.\n * The SMR database uses MyISAM for a storage engine, so we cannot simply rollback transactions after each test. Instead, the `BaseIntegrationSpec` will check for any tables that are populated from the `flyway` migration during startup, and truncate all other tables after your test.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsmrealms%2Fsmr","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsmrealms%2Fsmr","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsmrealms%2Fsmr/lists"}