Sha256: 9a80d5368b3918aa744df2d94b02253ff3489a5ac1ae3d5c67e96351a968a0c3
Contents?: true
Size: 1.68 KB
Versions: 2
Compression:
Stored size: 1.68 KB
Contents
#!/usr/bin/env php <?php $projectDirHost = dirname(dirname(dirname($_SERVER['PHP_SELF']))); $projectDirGuest = '/vagrant'; $homeDirHost = $projectDirHost . '/.idea/vagrant'; $homeDirGuest = $projectDirGuest . '/.idea/vagrant'; $pipe = 'vagrant ssh -c '; chdir($projectDirHost); // Detect Host IP $hostIpFile = $homeDirHost . '/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, $projectDirHost) !== false) { // Mapping project paths to remote paths $arguments[$index] = str_replace($projectDirHost, $projectDirGuest, $filePath); } else { // Mapping any other local system paths to remote paths, upload files if(!is_dir($homeDirHost . '/scripts/')) { mkdir($homeDirHost . '/scripts/', 0777, true); } copy($filePath, $homeDirHost . '/scripts/' . basename($filePath)); $arguments[$index] = $homeDirGuest . '/scripts/' . basename($filePath); } } $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
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
vagrant-phpstorm-tunnel-0.1.0 | data/php |
vagrant-phpstorm-tunnel-0.0.7 | data/php |