small/entity-schema

Standalone schema designer and code generator for Small Swoole Entity Manager.

Maintainers

Package info

git.small-project.dev/lib/small-entity-schema

Type:project

pkg:composer/small/entity-schema

Transparency log

Statistics

Installs: 95

Dependents: 0

Suggesters: 0

1.1.1 2024-12-18 19:10 UTC

README

Small Entity Schema 2

Small Entity Schema is a visual PHP entity schema designer and source updater for Small Swoole Entity Manager.

Version 2 is a Linux desktop application: the schema editor runs in its own window and edits a selected PHP project directly on disk.

Runtime baseline

  • PHP >= 8.3
  • small/swoole-entity-manager-core 3.0.0
  • small/class-manipulator 3.0.0
  • Symfony 7.4
  • Electron desktop shell
  • Svelte renderer
  • SQLite project registry through Electron's node:sqlite
  • no SwooleBundle or Small Forms dependency in the schema application

The root composer.json remains the canonical PHP application manifest. The packaged desktop application contains the PHP application code, Composer dependencies and a FrankenPHP static PHP runtime used only in CLI mode.

Development install

composer install

The old bin/schema-manager launcher remains available for backend development, but it is not used by the packaged desktop application.

Build the Linux desktop application

bin/build creates a windowed Linux application. Docker with Buildx is the only required build tool on the host:

bin/build

The generated launcher is:

dist/small-entity-schema

The AppImage payload is stored beside it:

dist/small-entity-schema.AppImage

Launch the application through the generated launcher:

./dist/small-entity-schema

The launcher enables AppImage extract-and-run mode automatically. This avoids the libfuse.so.2 runtime dependency on Linux systems where FUSE 2 is not installed. Keep the launcher and its .AppImage payload together when copying the built application.

Multiple projects

The desktop application keeps known PHP projects in projects.sqlite under Electron's per-user application-data directory.

The native Set project menu contains:

  • New project…: choose a directory containing composer.json; the normalized path is stored in SQLite and immediately becomes the active project.
  • Known projects: lists paths previously stored in SQLite. Selecting an available project makes it active. Paths that are no longer available stay visible but disabled.

The most recently opened known project is restored on startup unless PROJECT_PATH explicitly selects another valid project. If there is no valid known project, the current working directory is used when it contains composer.json; otherwise the project picker opens.

Changing project updates PROJECT_PATH, resets the renderer environment, reloads namespaces and entities from the selected project, and updates the window title. Entity layout cache is isolated per project so switching projects does not mix their diagram state.

A project can also be supplied through the environment:

PROJECT_PATH=/path/to/project ./dist/small-entity-schema

Desktop architecture

The packaged application does not start an HTTP server and does not bind a localhost TCP port.

The Svelte UI is compiled to static files and exposed to Electron through the in-process ses://app/ protocol. Renderer access to Node.js is disabled. A preload bridge exposes only the schema operations required by the UI. The custom protocol exists only inside Electron; it does not open a network listener.

Electron sends schema operations over IPC to its main process. The main process invokes the packaged PHP bridge with an absolute resource path:

small-entity-schema-runtime php-cli <app-resources>/runtime/app/bin/desktop-bridge <operation>

The backend application and its Composer vendor/ tree are packaged as explicit Electron resources beside the PHP runtime. This avoids depending on FrankenPHP's temporary extraction directory to locate the desktop bridge script.

The PHP desktop bridge validates the active PROJECT_PATH and invokes the schema application use cases directly for namespace discovery, entity loading and entity saving. Each bridge process opens only the currently selected project, so switching projects does not reuse a Symfony container or project-specific runtime state. JSON is exchanged over stdin/stdout; there is no HTTP transport between the UI and PHP.

Build options

The default build targets the current CPU architecture and PHP 8.3:

bin/build

Useful options:

bin/build --platform=linux/amd64
bin/build --platform=linux/arm64
bin/build --php-version=8.3
bin/build --libc=musl
bin/build --compress
bin/build --network=default
bin/build --output=dist/small-entity-schema-amd64

--output names the launcher; its AppImage payload is written to the same path with .AppImage appended. --libc controls the embedded PHP runtime. --compress applies UPX compression to that runtime before it is packaged into the desktop application.

Docker build networking defaults to host. COMPOSER_AUTH and GITHUB_TOKEN, when present, are passed into BuildKit as secrets instead of image build arguments.

The build validates the production PHP dependencies, Svelte desktop UI, PHP bridge against testproject, and the presence of the packaged bridge and Composer autoloader before Electron Builder creates the AppImage. The build then writes a FUSE-free launcher beside that payload.

The build context excludes repository metadata, existing vendor directories, frontend node modules, Svelte build output and caches. .git is never packaged.

Create a release

Start from a clean current branch that has already been pushed to origin, then choose exactly one semantic-version increment:

bash bin/release --patch
bash bin/release --minor
bash bin/release --major

The release helper updates the root .version, commits the change as chore: release vX.Y.Z, creates an annotated vX.Y.Z tag, and atomically pushes the branch and tag. The tag starts the GitLab quality, test, build, end-to-end and release pipeline.

Source preservation

Schema updates own only ORM-specific structure: generated ORM properties and the OrmEntity, PrimaryKey, Field, ToOne, ToMany, manager and collection metadata.

Custom methods and method bodies, interfaces, PHPDoc, non-ORM properties and non-ORM property attributes are kept during source updates.