Skip to content

Conversation

@Kern046
Copy link
Collaborator

@Kern046 Kern046 commented Jan 9, 2022

This Pull Request migrates the legacy codebase to the Symfony framework.

It also replaces the game request workflow.

Components

The game had a lot of homemade components as it did not use Composer or any kind of vendors at its creation.

Originally the game had its own server socket to listen incoming requests. It had all the engine services loaded, some of them were very stateful and contained different data per session. Now we are going to use a classical PHP-FPM architecture in production, and a PHP webserver in dev environment.

Homemade components are to be replaced with Symfony components :

  • Homemade Server => Symfony HttpKernel Component.
  • Homemade Router => Symfony Routing Component.
  • Homemade authentication => Symfony Security Component.
  • Homemade Service Container => Symfony DependencyInjection Component.
  • Homemade EventDispatcher => Symfony EventDispatcher Component.
  • Homemade ProcessManager and Worker system => Symfony Messenger Component.

Templates

A lot of logic were contained in the PHP view files, that are now being migrated to Twig. Some of this logic have been temporarly been moved to Twig Extensions but will finally be placed in dedicated services.

A TwigEventSubscriber has been implemented to set some custom global variables in the templates :

  • current_base contains the current player orbital base
  • incoming_commanders contains the list of the current base incoming commanders
  • outgoing_commanders contains the list of the current base outgoing commanders
  • current_dock1_ship_queues contains the list of light ships being crafted at the current base
  • current_dock2_ship_queues contains the list of heavy ships being crafted at the current base
  • next_base_id contains the ID of the player's next orbital base
  • current_base_name contains the name of the current base
  • current_base_image contains the picture of the current base
  • current_player contains the current player
  • current_player_faction_id contains the faction id of the current player
  • conversations_count contains the count of private messages received by the current player
  • current_player_notifications contains the list of the unread notifications of the current player

The biggest part of these variables are used in the main game layout. Some of them may be cleaned but are there to temporarly represent the legacy logic while migrating.

Argument Resolvers

Two argument resolvers have been introduced thanks to Symfony to inject session-related entities in the Controller :

  • OrbitalBase: contains the current player base
  • Player: contains the current player

As a player may have several bases, a later rework would be to implement an OrbitalBaseStack to keep in store the player bases and inject it properly.

Hexagonal Architecture

The domain were separated in different packages, named after greek gods. We are currently reorganizing these packages with the hexagonal architecture principles. Moving all the existing stuff to the right place will be done in time, but for now a few interfaces were created to factorize domain concepts, like QueueableInterface and TravellerInterface.

Remaining tasks

  • Enable the inscription system
  • Migrate the remaining views
  • Migrate all the user actions
  • Design a workflow to run the planned tasks with Messenger
  • Design a workflow to run the periodic tasks with Cron
  • Convert the items of the script interface into Symfony commands
  • Implement the production environment
  • Document the new setup
  • Document the contribution guidelines
  • Convert SQL init script into Doctrine Migration
  • Transform controller exceptions into alerts
  • Use Webpack to handle the assets

Linked Pull Requests

@Kern046 Kern046 self-assigned this Jan 9, 2022
@Kern046 Kern046 force-pushed the feature/remove-daemon-server branch 2 times, most recently from b0ca80e to 30a5356 Compare January 18, 2022 22:04
@Kern046 Kern046 changed the title Symfony full migration [EPIC] Symfony full migration Jan 22, 2022
@Kern046 Kern046 force-pushed the feature/remove-daemon-server branch from 8852551 to 4e8f798 Compare February 20, 2022 22:55
@Kern046 Kern046 force-pushed the feature/remove-daemon-server branch from 4f8348b to d34e41d Compare February 27, 2022 14:03
@Kern046 Kern046 mentioned this pull request Mar 13, 2022
@Kern046 Kern046 force-pushed the feature/remove-daemon-server branch from 5be9b3b to 766ade1 Compare March 27, 2022 22:54
This was referenced Mar 31, 2022
Kern046 added 27 commits April 8, 2025 01:26
… Mercure with broadcast upon transaction adding and removal
…atform

Remove all previous assets and migrate all frontend to Symfony UX, Tailwind and Stimulus
Implement game portal with registration and login
@Kern046 Kern046 marked this pull request as ready for review May 20, 2025 08:07
@Kern046 Kern046 merged commit 27b2bb7 into master May 20, 2025
@Kern046 Kern046 deleted the feature/remove-daemon-server branch May 20, 2025 08:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants