Sha256: 81628b20b5088ef86a988ade1bbbbe5052734779470af14170f71ade905dcf0f
Contents?: true
Size: 1.57 KB
Versions: 1
Compression:
Stored size: 1.57 KB
Contents
#!/usr/bin/env php <?php $projectDir = dirname(dirname(dirname($_SERVER['PHP_SELF']))); $homeDir = $projectDir . '/.idea/vagrant'; $tmpDir = $homeDir . '/tmp'; $vagrantDir = '/vagrant'; $pipe = 'vagrant ssh -c '; chdir($projectDir); // Detect Host IP $hostIpFile = $homeDir . '/host_ip'; if (!file_exists($hostIpFile)) { $ip = shell_exec('vagrant ssh -c "sudo ip route | awk \'/default/ { print \$3 }\'"'); file_put_contents($hostIpFile, $ip); } $hostIp = trim(file_get_contents($hostIpFile)); if (!filter_var($hostIp, FILTER_VALIDATE_IP)) { throw new Exception('Cannot detect host IP, got value `' . $hostIp . '`.'); } $arguments = $argv; array_shift($arguments); foreach ($arguments as $index => &$argument) { // IP mapping $argument = str_replace(array('127.0.0.1', 'localhost'), $hostIp, $argument); // Paths mapping $filePath = $argument; if (file_exists($filePath)) { if (strpos($filePath, $projectDir) !== false) { // Mapping project paths to remote paths $arguments[$index] = str_replace($projectDir, $vagrantDir, $filePath); } else { // Mapping any other local system paths to remote paths, upload files $basename = basename($filePath); copy($filePath, $projectDir . '/' . $tmpDir . '/tunnel.' . $basename); $arguments[$index] = $vagrantDir . '/' . $tmpDir . '/tunnel.' . $basename; } } $argument = escapeshellarg($argument); } // Get XDEBUG environment variable $env = ''; if (isset($_SERVER['XDEBUG_CONFIG'])) { $env = "XDEBUG_CONFIG='" . $_SERVER['XDEBUG_CONFIG'] . "'"; } passthru($pipe . '"' . $env . ' php ' . implode(' ', $arguments) . '"');
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
vagrant-phpstorm-tunnel-0.0.5 | data/php |