Sha256: 462492fc8210ec9226d57a61c5ddf4f147d72c6c0b83390521ea5b75b79be64d
Contents?: true
Size: 1.55 KB
Versions: 2
Compression:
Stored size: 1.55 KB
Contents
#!/usr/bin/env php <?php $scriptDir = __DIR__; $projectDir = ''; $projectTmpDir = '/tmp'; $vagrantDir = '/vagrant'; $vagrantIp = '10.10.10.1'; $pathCrumbs = explode('/', $scriptDir); while(count($pathCrumbs)) { $_path = implode('/', $pathCrumbs); if(is_dir($_path . '/.idea')) { $projectDir = $_path; break; } array_pop($pathCrumbs); } if (empty($projectDir)) { echo "Cannot detect project dir!"; exit; } $args = $_SERVER['argv']; foreach ($args as $index => &$arg) { // IP mapping $arg = str_replace(array('127.0.0.1', 'localhost'), $vagrantIp, $arg); // Paths mapping $filePath = $arg; if (file_exists($filePath)) { if (strpos($filePath, $projectDir) !== false) { // Mapping project paths to remote paths $args[$index] = str_replace($projectDir, $vagrantDir, $filePath); } else { if (strpos($filePath, $projectDir) === false) { // Mapping any other local system paths to remote paths, upload files $basename = basename($filePath); copy($filePath, $projectDir . $projectTmpDir . '/tunnel.' . $basename); $args[$index] = $vagrantDir . $projectTmpDir . '/tunnel.' . $basename; } } } $arg = escapeshellarg($arg); } array_shift($args); // Get XDEBUG environment variable $env = ''; if (isset($_SERVER['XDEBUG_CONFIG'])) { $env = "XDEBUG_CONFIG='" . $_SERVER['XDEBUG_CONFIG'] . "'"; } // Tunnel $pipe = 'vagrant ssh -c '; // Remote command $commandRemote = $env . ' php ' . implode(' ', $args); // Local command $commandLocal = 'cd ' . $projectDir . ' && ' . $pipe . '"' . $commandRemote . '"'; passthru($commandLocal); exit; ?>
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
vagrant-phpstorm-tunnel-0.0.4 | data/php |
vagrant-phpstorm-tunnel-0.0.3 | data/php |