UGTK cat mascotUGTKengine within an engine Request access

UGTK / Toolkit / API / PhpConnectionSystem Completed

API — UGTK

Php Connection System

Summary

The Php Connection System is the backbone of every server call in UGTK. One manager holds the server URL; every operation derives from Mn_PhpOperationBase and only has to declare what to send — the rest (URL resolution, the one-request-at-a-time guard, auto-execute, the repeat loop, the loading screen and the success/failure/offline events) comes for free.

The practical consequence: moving from a staging server to production means changing one field, not hunting for URLs across the project.


Content


Modules Dependencies


Setup

Add the PhpApiManager prefab to the scene — one per game — and set its Server Url:

From then on every operation only needs the file name (login.php), and the manager builds the full URL.


How To Use

On any operation component (this module's own, or one of the modules built on it — Email Sender, Leaderboard, Tickets, Leads…):

Field What it does
Php File Url file name appended to the server URL, or the whole URL if the next flag is on
Use Absolute Url bypass the manager: useful for a third-party endpoint
Table Name destination table, when the endpoint expects one
Auto Execute On Awake fire the call as soon as the object wakes
Loop Operation + Loop Delay Seconds keep repeating: this is the polling of the toolkit
Use Loading Screen show the shared loading overlay while in flight
Debug Mode log request and response

Three events tell the three outcomes apart:

Good to know:


Writing Your Own Operation

public class Mn_MyOperation : Mn_PhpOperationBase
{
    public string playerName;

    protected override WWWForm BuildFormData()
    {
        var form = new WWWForm();
        form.AddField("table", tableName);
        form.AddField("name", playerName);
        return form;                    // throw or return null to fail cleanly
    }

    protected override void ExecuteOperation(WWWForm formData) { /* send it */ }
}

Throwing inside BuildFormData is a supported way to refuse: the exception is caught and reported through OnFailure with its message, instead of escaping into the console.


Testing Scene

Open PhpSystemScene in the module's Debug/ folder.

What to do, in order:

  1. Point the operation at your endpoint and press Execute().
  2. Point it at a URL that returns a 404.
  3. Point it at a URL that returns HTML instead of the expected payload.

Step 3 is the failure that wastes an afternoon: the request succeeds, the status is 200, and the parse fails on what turns out to be a hosting error page. Read the raw response before blaming the parser.

Then do the test everybody skips: turn the network off and repeat. A request that never answers is the normal condition on mobile, and it is where a game most often ends up stuck on a spinner with no way back.

PhpSystemScene holds one object: the manager, and the manager holds one thing that matters - the server URL every operation in the package is resolved against. The recording is the pair of helpers next to it, Copy / Paste / Clear, which is how you move that URL between the manager and the individual operations without retyping it and getting one character wrong.

There is nothing to run here on purpose: this module has no request of its own. To see one leave the machine, open any operation that inherits from it - AppInfoStats, Tickets, LeadsGeneration - turn on Debug Mode and press Execute; the console then prints the URL this manager gave it.


Technical Info

Path Content
Scripts/Mn_PhpManager.cs The singleton holding the server URL, with GetPhpFileUrl
Scripts/Mn_PhpOperationBase.cs The base: URL mode, auto/loop, loading screen, in-flight guard, the three events, Execute and the two abstract members
Scripts/PhpResponse.cs The status + message answer every endpoint returns
Scripts/Editor/Mn_PhpOperationBaseEditor.cs Shared inspector with the Execute button, reusable by derived inspectors
Prefabs/PhpApiManager.prefab The ready-made manager

© 2026 Marcello De Bonis. All rights reserved

Real dependenciesOpen in the map →

Measured from the repository: code references (asmdef) plus prefab and asset GUIDs. Importing this module alone brings in 3 modules in total.