valzargaming / php-osc
Open Sound Control (OSC) Client Library for PHP
Installs: 5
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 0
Forks: 11
pkg:composer/valzargaming/php-osc
Requires
- php: >=8.1.2
- ext-sockets: *
- react/datagram: ^1.8
- react/event-loop: ^1.2
- trafficcophp/bytebuffer: ^0.3
Requires (Dev)
- friendsofphp/php-cs-fixer: ^3.9
- phpunit/phpunit: ^10.0
Suggests
- ext-pcntl: For graceful shutdown on UNIX-like systems.
- react/async: For async/await capabilities with Promises.
- react/cache: For caching.
This package is auto-updated.
Last update: 2026-01-27 17:44:08 UTC
README
Install the dependencies with Composer:
Run composer install to install the project dependencies.
Bot example
A production-ready example, bot.php, is included. It sends periodic OSC messages (sender-only).
Listener and acknowledgement functionality has been moved to the separate entrypoint script osc_listener.php.
Environment variables for bot.php:
OSC_DEST– remote IP to send messages to (default127.0.0.1)OSC_PORT– remote port to send messages to (default9000)OSC_INTERVAL– send interval in seconds (default5)OSC_ADDRESS– OSC address for heartbeat messages (default/bot/heartbeat)
Examples:
Run the bot with defaults:
php bot.php
Send to a custom destination:
OSC_DEST=192.168.1.50 OSC_PORT=3890 OSC_INTERVAL=2 OSC_ADDRESS=/my/bot php bot.php
Start the separate listener (acknowledgement service) in another terminal:
php osc_listener.php
Examples
See examples.md for more usage examples, including the ReactPHP UDP server (server.php) and how to run it together with bot.php for end-to-end testing.
php-osc
PSR-4 version of Open Sound Control (OSC) Client Library for PHP
Authors:
- Andy W. Schmeder andy@a2hd.com (original, 2003-2007)
- Jason Soares jsoares@theexperiment.org (PSR-4 update)
- Valithor Obsidion valithor@discordphp.org (maintainer, 2026-present)
Copyright:
- Copyright (c) 2003-2007 Andy W. Schmeder
- Copyright (c) 2026-present Valithor Obsidion
Version: 2.0
Requirements: PHP >= 8.1.2
For information about Open Sound Control, see http://www.opensoundcontrol.org/
Known Issues
-
Listener callbacks in automated tests: The earlier external-process integration test (starting
server.phpandosc_listener.phpas detached processes) failed to observe the server->listener callback in the automated PHPUnit run on Windows. This was caused by process-start timing and platform-specific spawn/quoting behavior. As a result we now provide an in-process integration test that is reliable under PHPUnit: tests/IntegrationTest.php. -
Manual run that did work: A manual interactive run did exercise the end-to-end flow successfully — start the server and listener, send a probe, and observe the callback/ack cycle in the logs. Example commands used interactively in PowerShell:
-
Start the server (foreground):
php server.php
-
Start the listener (foreground):
php osc_listener.php
-
Send a probe to trigger the server callback (helper script):
php tests/probe_9001.php
The listener log (osc-listener.log) then shows the received probe and the ack sent back.
-
-
Why this matters: If you rely on automated external-process integration tests on Windows CI, prefer the in-process ReactPHP test harness provided in tests/IntegrationTest.php or run the manual commands interactively. If you want the external-process test to work in CI, it may require platform-specific adjustments to process startup and timeouts.