Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>I've got something that works reasonably well on my machine, but it seems fragile.</p> <h1>The Idea</h1> <p>The idea here is to create a command-line script on your host that passes all its parameters to a PHP call on your VM, via an SSH tunnel. SublimeLinter can then call this script as it would usually call the PHP binary, and from Sublime's point of view everything will "just work" without having to install PHP on your host.</p> <p>I'm using both Windows and OS X hosts so I've got two versions of my tunnel script. Note that on Windows you'll need to fetch the Windows PuTTY SSH tools, but for Unix-flavored hosts SSH will likely already be present.</p> <h1>For Windows Hosts</h1> <p><ul> <li>Download the <a href="http://the.earth.li/~sgtatham/putty/latest/x86/putty.zip" rel="nofollow">putty</a> tools and unzip them somewhere useful like <code>C:/Users/Youruser/bin/putty</code>.</li> <li>Create the batch script at <code>C:/Users/Youruser/bin/php_vm_tunnel.bat</code> with this content:</p> <blockquote> <pre><code>@echo off C:/Users/Youruser/bin/putty/plink -l youruser -pw yourpassword 192.168.56.101 php %* </code></pre> <p></li> </ul> <em>NOTE</em> - be sure and replace the path to plink with the correct path where you unzipped putty above. Also, replace the <code>-l</code> and <code>-pw</code> flag values with the username and password that you use when you SSH into your VM. Finally, be sure and replace the IP address in the example with the IP address you use to SSH into your VM.</p> </blockquote> <h1>For Unix-ish Hosts (OS X, Linux, etc)</h1> <p><ul> <li>Create the bash script at <code>~\bin\php_vm_tunnel</code></p> <blockquote> <pre><code>#!/usr/bin/env bash FIXED_ARGS=''; for (( i = 1; i &amp;lt;= $# ; i++ )); do eval ARG=\$$i FIXED_ARGS="$FIXED_ARGS $(echo "$ARG" | awk '{gsub(".", "\\&amp;amp;");print}')" done ssh -l root 192.168.56.101 php $FIXED_ARGS </code></pre> <p></li> </ul> <em>NOTE</em> - be sure to replace the <code>-l</code> flag value with the username that you use when you SSH into your VM. Also, be sure to replace the IP address in the example with the IP address you use to SSH into your VM.</p> </blockquote> <h1>Testing the Script</h1> <p>At this point you have a script that should tunnel anything you pass to it through to your VM. So if in a terminal you were to do, say:</p> <blockquote> <pre><code>cd wherever_you_put_the_script php_vm_tunnel -v </code></pre> </blockquote> <p>You should see the PHP version info return from your virtual machine.</p> <h1>Sublime Text 2 Configuration</h1> <p>Now that you have this tunnel set up, you can configure Sublime Text 2 to make use of it:</p> <ul> <li>Install the <code>Package Control</code> Sublime Text 2 plugin</li> <li>Install the <code>SublimeLinter</code> plugin (it sounds like you were already at this point)</li> <li>Go to <code>Preferences</code> -> <code>Package Settings</code> -> <code>SublimeLinter</code> -> <code>Settings - User</code></li> <li><p>Add this to the configuration file (again substituting in the proper path to the script and noting the double slashes to properly escape the backslash characters) and save:</p> <blockquote> <pre><code>{ "sublimelinter_executable_map": { "php": "C:\\\Users\\\Youruser\\\bin\\\php_vm_tunnel.bat" "php": "/Users/youruser/bin/php_vm_tunnel" } } </code></pre> </blockquote> <p><em>NOTE</em> - You can only have one "php" statement. The first one above is the Windows version, the second one is the Unix version. Delete the one you don't need.</p></li> <li>restart Sublime Text</li> </ul> <p>If you open the Sublime Text console (and everything went according to plan) you should see something in the startup text like like:</p> <blockquote> <pre><code>SublimeLinter: php enabled (using "C:\Users\Youruser\bin\php_vm_tunnel.bat" for executable) </code></pre> </blockquote> <p>And SublimeLinter should be properly linting PHP files as if it were calling a native PHP binary.</p> <p>Good luck.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload