Releases: phpnomad/nativephp-integration
v0.2.0 — strategy interfaces for all Features
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 toPHPNomad\NativePHP\Integration\Strategies\*with theStrategysuffix 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
InitializerBindingsTestverifies 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
LoggingNotificationthat just writes to stdout - A cross-platform
XclipClipboardthat bypasses Electron for CLI scenarios - An encrypted-at-rest
Settingsdecorator - 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
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 anUnknownNativeEventcatch-all, translated from the raw JS event names byEventTranslator - REST controllers for the inbound callback routes (
/_native/api/booted,/_native/api/events,/_native/api/cookie) viaphpnomad/fastroute-rest-integration, with a secret-headerSecretGuardmiddleware - Symfony Console commands (
native:config,native:php-ini,native:serve) viaphpnomad/symfony-console-integration - Declarative
WindowManager— registerWindowDefinitionobjects once; the integration opens them at boot via theOpenWindowsOnBootlistener - HTTP
ClientwithX-NativePHP-Secretheader and typedNativePHPException
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-integrationfor local dataphpnomad/symfony-event-dispatcher-integrationfor event handlingphpnomad/json-config-integrationfor app config
Known gaps (planned follow-ups, not blockers for usage)
- No
phpnomad/electron-app-starterscaffold yet —sandbox/is the working reference phpnomad/symfony-console-integrationrequiresdev-mainuntil a1.0.5tag is cut (the fix forbindFactoryis onmainbut not in1.0.4)- No
nativephp/php-binwiring for portable PHP runtimes (needed for distributable installers) - No auto-updater event surface yet
Install
composer require phpnomad/nativephp-integration:^0.1.0See README for the full setup, including the Electron-side patch-package recipe.