PHPackages                             toxicity/symfony-native-bridge - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. toxicity/symfony-native-bridge

ActiveSymfony-bundle

toxicity/symfony-native-bridge
==============================

Build native desktop applications with Symfony — powered by Electron or Tauri

510PHPCI failing

Since Mar 19Pushed 1mo agoCompare

[ Source](https://github.com/toxicity1985/symfony-native-bridge)[ Packagist](https://packagist.org/packages/toxicity/symfony-native-bridge)[ RSS](/packages/toxicity-symfony-native-bridge/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependenciesVersions (1)Used By (0)

SymfonyNativeBridge
===================

[](#symfonynativebridge)

> Build native desktop applications with Symfony — powered by **Electron** or **Tauri**.

The spiritual equivalent of [NativePHP](https://nativephp.com) for the Symfony ecosystem.
Write standard Symfony controllers, services and events — ship a `.exe`, `.dmg`, or `.AppImage`.

---

How it works
------------

[](#how-it-works)

```
┌──────────────────────────────────────────────┐
│           Your Symfony Application            │
│  Controllers · Twig · API Platform · etc.    │
└─────────────────────┬────────────────────────┘
                      │ HTTP (loopback)
┌─────────────────────▼────────────────────────┐
│         SymfonyNativeBridgeBundle             │
│                                              │
│  WindowManager   TrayManager                 │
│  NotificationManager   DialogManager         │
│  AppManager      StorageManager              │
└─────────────────────┬────────────────────────┘
                      │ WebSocket / named pipe (IPC)
┌─────────────────────▼────────────────────────┐
│         Electron / Tauri (runtime)            │
│  BrowserWindow · Tray · Notification         │
│  shell · dialog · autoUpdater · store        │
└──────────────────────────────────────────────┘

```

1. `native:serve` starts a PHP built-in server on `127.0.0.1:8765`
2. It spawns the native runtime (Electron or Tauri), which opens a `BrowserWindow` pointing at that URL
3. PHP and the runtime communicate over a **WebSocket IPC** (Electron) or **named pipe** (Tauri)
4. PHP services call `driver->call('window.open', …)` → native JS/Rust handles it → returns the result
5. Native events (tray clicks, window focus, …) are pushed back to PHP and dispatched as **Symfony events**

---

Requirements
------------

[](#requirements)

ElectronTauri**Node.js**≥ 18≥ 18**Rust / Cargo**✗ not needed✓ required**PHP**≥ 8.2≥ 8.2**Symfony**^6.4 or ^7^6.4 or ^7---

Installation
------------

[](#installation)

```
composer require toxicity/symfony-native-bridge
```

Register the bundle in `config/bundles.php`:

```
return [
    // ...
    SymfonyNativeBridge\SymfonyNativeBridgeBundle::class => ['all' => true],
];
```

Install the native runtime (one-time):

```
# Electron (default)
php bin/console native:install

# Tauri
php bin/console native:install --driver=tauri
```

---

Configuration
-------------

[](#configuration)

```
# config/packages/symfony_native_bridge.yaml
symfony_native_bridge:
    driver: electron          # "electron" | "tauri"

    app:
        name:        "My App"
        version:     "1.0.0"
        identifier:  "com.example.my-app"

    window:
        width:   1280
        height:  800

    updater:
        enabled: false
        url:     ~

    build:
        output_dir: dist
        targets:    [current]   # or [windows, macos, linux]
```

---

Usage
-----

[](#usage)

### Start in development

[](#start-in-development)

```
php bin/console native:serve
```

This starts both the PHP server and the Electron/Tauri window in one command.

### Build for distribution

[](#build-for-distribution)

```
# Current platform
php bin/console native:build

# Cross-compile (requires appropriate toolchain)
php bin/console native:build --target=windows --target=macos --target=linux
```

---

Services
--------

[](#services)

All services are **autowirable** — just type-hint in your constructor.

### WindowManager

[](#windowmanager)

```
use SymfonyNativeBridge\Service\WindowManager;
use SymfonyNativeBridge\ValueObject\WindowOptions;

class MyController
{
    public function __construct(private WindowManager $window) {}

    public function openSettings(): void
    {
        $id = $this->window->open(
            url: 'http://127.0.0.1:8765/settings',
            options: new WindowOptions(width: 600, height: 400, title: 'Settings'),
        );
    }
}
```

### TrayManager

[](#traymanager)

```
use SymfonyNativeBridge\Service\TrayManager;
use SymfonyNativeBridge\ValueObject\MenuItem;

// Create tray icon
$this->tray->create('/path/to/icon.png', 'My App', 'main');

// Set context menu
$this->tray->menu('main', [
    new MenuItem(label: 'Open',  id: 'open'),
    MenuItem::separator(),
    new MenuItem(label: 'Quit',  id: 'quit', role: 'quit'),
]);
```

### NotificationManager

[](#notificationmanager)

```
use SymfonyNativeBridge\Service\NotificationManager;

$this->notification->send('Task complete', 'Your export is ready.');
```

### DialogManager

[](#dialogmanager)

```
use SymfonyNativeBridge\Service\DialogManager;

// File picker
$paths = $this->dialog->openFile('Choose a CSV', filters: [
    ['name' => 'CSV Files', 'extensions' => ['csv']],
]);

// Confirm dialog
if ($this->dialog->confirm('Delete this item?')) {
    // ...
}

// Save dialog
$dest = $this->dialog->saveFile('Save As', defaultPath: '~/export.pdf');
```

### StorageManager (persistent key-value store)

[](#storagemanager-persistent-key-value-store)

```
use SymfonyNativeBridge\Service\StorageManager;

$this->storage->set('theme', 'dark');
$theme = $this->storage->get('theme', 'light'); // 'dark'

// Memoize
$token = $this->storage->remember('auth_token', fn() => $this->auth->generateToken());
```

### AppManager

[](#appmanager)

```
use SymfonyNativeBridge\Service\AppManager;

$this->app->getPath('appData');           // /home/user/.config/my-app
$this->app->openExternal('https://…');    // opens in default browser
$this->app->showItemInFolder('/path/to'); // opens file manager
$this->app->checkForUpdates();            // triggers auto-updater
$this->app->quit();
```

---

Listening to native events
--------------------------

[](#listening-to-native-events)

Use `#[AsNativeListener]` — no YAML needed:

```
use SymfonyNativeBridge\Attribute\AsNativeListener;
use SymfonyNativeBridge\Event\AppReadyEvent;
use SymfonyNativeBridge\Event\TrayMenuItemClickedEvent;
use SymfonyNativeBridge\Event\AppBeforeQuitEvent;

class AppBootstrap
{
    public function __construct(
        private TrayManager $tray,
        private AppManager  $app,
    ) {}

    #[AsNativeListener(AppReadyEvent::class)]
    public function onReady(AppReadyEvent $event): void
    {
        $this->tray->create('/assets/icon.png', 'My App', 'main');
    }

    #[AsNativeListener(TrayMenuItemClickedEvent::class)]
    public function onMenuClick(TrayMenuItemClickedEvent $event): void
    {
        if ($event->menuItemId === 'quit') {
            $this->app->quit();
        }
    }

    #[AsNativeListener(AppBeforeQuitEvent::class)]
    public function onQuit(AppBeforeQuitEvent $event): void
    {
        // Prevent accidental quit
        $event->prevent();
    }
}
```

### Full list of native events

[](#full-list-of-native-events)

Event classConstantTriggered when`AppReadyEvent``native.app.ready`Runtime is up and first window is open`AppBeforeQuitEvent``native.app.before_quit`User tries to quit (call `$event->prevent()` to cancel)`AppActivatedEvent``native.app.activated`macOS: app clicked in Dock`WindowFocusedEvent``native.window.focused`A window gains focus`WindowBlurredEvent``native.window.blurred`A window loses focus`WindowClosedEvent``native.window.closed`A window is closed`WindowResizedEvent``native.window.resized`A window is resized`WindowMovedEvent``native.window.moved`A window is moved`TrayClickedEvent``native.tray.clicked`Tray icon clicked (`button`: left/right/double)`TrayMenuItemClickedEvent``native.tray.menu_item_clicked`A tray menu item is clicked`UpdateAvailableEvent``native.updater.update_available`A new version is found`UpdateDownloadedEvent``native.updater.update_downloaded`Update fully downloaded`NotificationClickedEvent``native.notification.clicked`User clicks a notification---

Architecture
------------

[](#architecture)

### Driver abstraction

[](#driver-abstraction)

Both runtimes implement the same `NativeDriverInterface`, so you can swap Electron ↔ Tauri by changing one line in your config:

```
symfony_native_bridge:
    driver: tauri   # was: electron
```

### IPC Protocol

[](#ipc-protocol)

Each PHP → runtime message:

```
{ "id": "", "action": "window.open", "payload": { "url": "…", "width": 1200 } }
```

Each runtime → PHP response:

```
{ "id": "", "ok": true, "result": "win_42" }
```

Push events from runtime → PHP (no `id`):

```
{ "event": "tray.clicked", "payload": { "trayId": "tray_1", "button": "right" } }
```

---

Running tests
-------------

[](#running-tests)

```
composer install
vendor/bin/phpunit
```

---

Roadmap
-------

[](#roadmap)

- Symfony Messenger transport for async native calls
- Hot-reload support in `native:serve` dev mode
- `#[NativeRoute]` attribute for URL-less window routing
- PHP binary embedding &amp; cross-compilation guide
- Multi-window management with named window registry
- macOS Menu Bar app mode (no Dock icon)
- Deep-link / protocol handler registration
- Clipboard API service

---

License
-------

[](#license)

MIT

###  Health Score

23

—

LowBetter than 27% of packages

Maintenance60

Regular maintenance activity

Popularity12

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity11

Early-stage or recently created project

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

### Community

Maintainers

![](https://www.gravatar.com/avatar/a0ed55b3d6685970ae7804f04238ed5c150efb307e85d08c0827fb1739d52c74?d=identicon)[Toxicity](/maintainers/Toxicity)

---

Top Contributors

[![toxicity1985](https://avatars.githubusercontent.com/u/708329?v=4)](https://github.com/toxicity1985 "toxicity1985 (12 commits)")

### Embed Badge

![Health badge](/badges/toxicity-symfony-native-bridge/health.svg)

```
[![Health](https://phpackages.com/badges/toxicity-symfony-native-bridge/health.svg)](https://phpackages.com/packages/toxicity-symfony-native-bridge)
```

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
