https://github.com/crowdstar/svn-agent-host
A native messaging host to handle SVN commands received from specific Chrome extension.
https://github.com/crowdstar/svn-agent-host
chrome native-messaging native-messaging-host php
Last synced: 2 months ago
JSON representation
A native messaging host to handle SVN commands received from specific Chrome extension.
- Host: GitHub
- URL: https://github.com/crowdstar/svn-agent-host
- Owner: Crowdstar
- License: apache-2.0
- Created: 2018-04-11T23:35:19.000Z (about 8 years ago)
- Default Branch: master
- Last Pushed: 2024-06-04T20:34:52.000Z (about 2 years ago)
- Last Synced: 2025-12-14T18:43:07.129Z (6 months ago)
- Topics: chrome, native-messaging, native-messaging-host, php
- Language: PHP
- Homepage:
- Size: 208 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
Awesome Lists containing this project
README
[](https://travis-ci.org/Crowdstar/svn-agent-host)
[](https://ci.appveyor.com/project/deminy/svn-agent-host)
[](https://packagist.org/packages/crowdstar/svn-agent-host)
[](https://packagist.org/packages/crowdstar/svn-agent-host)
[](https://packagist.org/packages/crowdstar/svn-agent-host)
A native messaging host to handle SVN commands received from specific Chrome extension.
The host program is built for Mac and Linux. For Windows users, you may have the host program installed in Ubuntu or
some other Linux distribution through the _Windows Subsystem for Linux_.
This repository was for an internal project at [Glu Mobile](https://www.glu.com). We make part of the whole project open
source to share our experience on
* writing [native messaging host](https://developer.chrome.com/apps/nativeMessaging#native-messaging-host) in PHP.
* wrapping Subversion operations in PHP without using [the Subversion extension](http://php.net/manual/en/book.svn.php).
# Run Tests
We use _Docker_ to setup our test environments. You may run unit tests, coding style checks, and other tests on
different versions of PHP and Subversion installations (prepared with _Docker_) using following commands:
```bash
PHP_VERSION=7.0 SVN_VERSION=1.8.19 ./bin/ci-on-linux.sh
PHP_VERSION=7.1 SVN_VERSION=1.9.9 ./bin/ci-on-linux.sh
PHP_VERSION=7.2 SVN_VERSION=1.10.3 ./bin/ci-on-linux.sh
PHP_VERSION=7.3 SVN_VERSION=1.11.0 ./bin/ci-on-linux.sh
PHP_VERSION=7.4 SVN_VERSION=1.13.0 ./bin/ci-on-linux.sh
# or, more specifically:
PHP_VERSION=7.1.19 SVN_VERSION=1.10.0 ./bin/ci-on-linux.sh
```
To run unit tests with current PHP and Subversion installation on your box, just execute following commands directly:
```bash
./bin/ci-on-osx.sh
```
# Demo Code
Following demo code shows how to communicate with the native message host from a Chrome extension.
```javascript
// content.js: a Content Script file.
window.addEventListener(
"message",
function (event) {
chrome.runtime.sendMessage(
event.data,
function (response) {
console.log('response from the background script', response);
}
);
},
false
);
window.postMessage({action: "create", data: {"path": "path/1"}}, "*");
// background.js: a Background Script file.
chrome.runtime.onMessage.addListener(
function (request, sender, sendResponse) {
chrome.runtime.sendNativeMessage(
'com.glu.crowdstar.svnagent', // name of the native messaging host.
request,
function (response) {
console.log("response from the native messaging host: ", response);
// sendResponse(response);
}
);
return true;
}
);
```