Skip to content

Releases: phpnomad/nativephp-integration

v0.2.0 — strategy interfaces for all Features

26 May 20:38

Choose a tag to compare

Adds strategy interfaces for all 17 Feature classes, aligning the package with how the rest of the PHPNomad ecosystem treats public surfaces. The previous concrete-only Features were inconsistent with PHPNomad's swap-anything-at-the-strategy-layer convention, and v0.1 was called out (rightly) for it.

What changed

  • 17 new interfaces in PHPNomad\NativePHP\Integration\Interfaces\: NotificationStrategy, WindowStrategy, DialogStrategy, ClipboardStrategy, ShellStrategy, SettingsStrategy, ScreenStrategy, SystemStrategy, DockStrategy, MenuBarStrategy, MenuStrategy, ContextMenuStrategy, PowerMonitorStrategy, GlobalShortcutStrategy, ProgressBarStrategy, ProcessStrategy, AlertStrategy.
  • PHPNomad\NativePHP\Integration\Features\* moved to PHPNomad\NativePHP\Integration\Strategies\* with the Strategy suffix on class names. Each concrete class now implements its interface.
  • Initializer::getClassDefinitions() binds every concrete → interface, so consumers resolve via the interface and can rebind any of them with their own implementation (a mock for tests, a logger-backed notifier, an xclip-backed clipboard, an in-memory settings store, etc.) without modifying this package.
  • New InitializerBindingsTest verifies every strategy actually resolves through its interface in the container. Total test count goes from 23 → 41 (104 assertions). Zero behavior change at runtime — only the public type surface expanded.

Why it matters

PHPNomad's whole positioning rests on swappability. LoggerStrategy, EventStrategy, ConsoleStrategy, QueryStrategy etc. are all interface-backed for that reason. Having 17 Feature classes that consumers could only type against concretely was a real anti-pattern relative to the rest of the ecosystem.

It also unlocks practical things:

  • Per-feature mocking in tests (instead of mocking the underlying transport)
  • A test/headless LoggingNotification that just writes to stdout
  • A cross-platform XclipClipboard that bypasses Electron for CLI scenarios
  • An encrypted-at-rest Settings decorator
  • Future Tauri (or other) implementations of the same domain interfaces

Breaking change

PHPNomad\NativePHP\Integration\Features\X has moved to PHPNomad\NativePHP\Integration\Strategies\XStrategy. Consumer code that typed against the concrete Features\X class will need to update the namespace and class name.

Recommended migration: type against Interfaces\XStrategy instead, so future swaps don't require code changes:

// Before
use PHPNomad\NativePHP\Integration\Features\Notification;
$container->get(Notification::class)->title(...)->show();

// After (recommended)
use PHPNomad\NativePHP\Integration\Interfaces\NotificationStrategy;
$container->get(NotificationStrategy::class)->title(...)->show();

Still v0.x

The Electron-side patch (NativePHP/electron#265) remains the gate to v1.0.0. Once that merges, this package will tag v1.0.0 — at which point the only API change from v0.2 will be the patch-package step going away.

v0.1.0 — experimental preview

26 May 19:58

Choose a tag to compare

Pre-release

Initial release of phpnomad/nativephp-integration. PHPNomad host adapter for NativePHP — lets a PHPNomad app run as the PHP guest inside an Electron desktop process, without Laravel.

Tagged as a prerelease because of one outstanding upstream dependency (see "Status" below). The package itself is functionally complete, end-to-end verified against real Electron, and stable enough to build against. When the upstream patch lands, this tags v1.0.0 with no API changes.

What's included

  • 17 fluent feature classes for the Electron API: Notification, Window, Dialog, Clipboard, Shell, Settings, Screen, System, Dock, MenuBar, Menu, ContextMenu, PowerMonitor, GlobalShortcut, ProgressBar, Process, Alert
  • Typed event classes for Electron's outbound webhooks (AppBooted, WindowFocused, WindowBlurred, WindowMinimized, WindowMaximized, WindowShown, WindowClosed, WindowResized, AppOpenedFromUrl, NotificationClicked) plus an UnknownNativeEvent catch-all, translated from the raw JS event names by EventTranslator
  • REST controllers for the inbound callback routes (/_native/api/booted, /_native/api/events, /_native/api/cookie) via phpnomad/fastroute-rest-integration, with a secret-header SecretGuard middleware
  • Symfony Console commands (native:config, native:php-ini, native:serve) via phpnomad/symfony-console-integration
  • Declarative WindowManager — register WindowDefinition objects once; the integration opens them at boot via the OpenWindowsOnBoot listener
  • HTTP Client with X-NativePHP-Secret header and typed NativePHPException

End-to-end verified against real Electron: windows open, notifications fire, events flow Electron→PHP, listeners can fire responses back. 23 tests / 69 assertions cover the wire format, event translation, the window manager, and the typed event API.

Status — why prerelease

The Electron-side @nativephp/electron-plugin is currently Laravel-coupled in three small places (the 'artisan' bin name in commands, the Laravel server.php router path, and the artisan optimize/artisan migrate calls in serveApp). A minimal three-env-var patch that opens those up for non-Laravel guests is open at NativePHP/electron#265.

Until that merges, consumers apply the same patch locally via patch-package — about two extra lines in their package.json. The patch file is bundled in this repo at sandbox/electron/patches/@nativephp+electron-plugin+0.5.5.patch. Full setup walkthrough is in the README.

When PR #265 merges and ships in a NativePHP release, the patch step goes away and this package tags v1.0.0 without API changes.

Compose with

  • phpnomad/db + phpnomad/sqlite-integration for local data
  • phpnomad/symfony-event-dispatcher-integration for event handling
  • phpnomad/json-config-integration for app config

Known gaps (planned follow-ups, not blockers for usage)

  • No phpnomad/electron-app-starter scaffold yet — sandbox/ is the working reference
  • phpnomad/symfony-console-integration requires dev-main until a 1.0.5 tag is cut (the fix for bindFactory is on main but not in 1.0.4)
  • No nativephp/php-bin wiring for portable PHP runtimes (needed for distributable installers)
  • No auto-updater event surface yet

Install

composer require phpnomad/nativephp-integration:^0.1.0

See README for the full setup, including the Electron-side patch-package recipe.