Skip to content

Commit

Permalink
feat: add hostname option to set the interface to bind to (#330)
Browse files Browse the repository at this point in the history
  • Loading branch information
martin-schulze-vireso authored and felixfbecker committed Mar 6, 2019
1 parent 59cd7fb commit c7280b6
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 6 deletions.
16 changes: 11 additions & 5 deletions .travis.yml
Expand Up @@ -2,7 +2,7 @@ language: php

php:
- '5.6'
- '7.0'
- '7.1'
env:
global:
- NODE_VERSION=8.9.3
Expand Down Expand Up @@ -45,11 +45,17 @@ jobs:
before_install:
# Fix ruby error https://github.com/Homebrew/brew/issues/3299
- brew update
- brew install php@7.0
- brew link --force --overwrite php@7.0
- brew install php@7.1
- brew link --force --overwrite php@7.1
- mkdir -p /usr/local/etc/php/7.1/conf.d
- cp travis-php.ini /usr/local/etc/php/7.1/conf.d/
# see per https://javorszky.co.uk/2018/05/03/getting-xdebug-working-on-php-7-2-and-homebrew/
# avoid problems with brew's symlink and pecl's recursive mkdir
- rm /usr/local/Cellar/php@7.1/7.1.26/pecl
- pecl install xdebug-$XDEBUG_VERSION
- mkdir -p /usr/local/etc/php/7.0/conf.d
- cp travis-php.ini /usr/local/etc/php/7.0/conf.d/
# make xdebug.so available at pecl's expected location
- ln -s /usr/local/Cellar/php@7.1/7.1.26/pecl/ /usr/local/lib/php/pecl
- php -i
- source ~/.nvm/nvm.sh
- nvm install $NODE_VERSION
- nvm use $NODE_VERSION
Expand Down
1 change: 1 addition & 0 deletions README.md
Expand Up @@ -45,6 +45,7 @@ In your project, go to the debugger and hit the little gear icon and choose _PHP
#### Supported launch.json settings:

- `request`: Always `"launch"`
- `hostname`: The address to bind to when listening for XDebug (default: all IPv6 connections if available, else all IPv4 connections)
- `port`: The port on which to listen for XDebug (default: `9000`)
- `stopOnEntry`: Wether to break at the beginning of the script (default: `false`)
- `pathMappings`: A list of server paths mapping to the local source paths on your machine, see "Remote Host Debugging" below
Expand Down
5 changes: 5 additions & 0 deletions package.json
Expand Up @@ -175,6 +175,11 @@
"description": "Environment variables passed to the program.",
"default": {}
},
"hostname": {
"type": "string",
"description": "Address to bind to when listening for XDebug",
"default": "::"
},
"port": {
"type": "number",
"description": "Port on which to listen for XDebug",
Expand Down
8 changes: 7 additions & 1 deletion src/phpDebug.ts
Expand Up @@ -50,6 +50,8 @@ function formatPropertyValue(property: xdebug.BaseProperty): string {
* This interface should always match the schema found in the mock-debug extension manifest.
*/
interface LaunchRequestArguments extends VSCodeDebugProtocol.LaunchRequestArguments {
/** The address to bind to for listening for XDebug connections (default: all IPv6 connections if available, else all IPv4 connections) */
hostname?: string
/** The port where the adapter should listen for XDebug connections (default: 9000) */
port?: number
/** Automatically stop target after launch. If not specified, target does not stop. */
Expand Down Expand Up @@ -310,7 +312,11 @@ class PhpDebugSession extends vscode.DebugSession {
this.sendEvent(new vscode.OutputEvent(util.inspect(error) + '\n'))
this.sendErrorResponse(response, <Error>error)
})
server.listen(args.port || 9000, (error: NodeJS.ErrnoException) => (error ? reject(error) : resolve()))
server.listen(
args.port || 9000,
args.hostname,
(error: NodeJS.ErrnoException) => (error ? reject(error) : resolve())
)
})
try {
if (!args.noDebug) {
Expand Down

0 comments on commit c7280b6

Please sign in to comment.