vagrant-phpstorm-tunnel 0.0.4 → 0.0.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +17 -17
- data/data/php +28 -43
- data/lib/vagrant-phpstorm-tunnel.rb +5 -5
- data/lib/vagrant-phpstorm-tunnel/configurator.rb +9 -11
- metadata +11 -11
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1d9482a0100d5aa82f72d85ec121f834ed681449
|
4
|
+
data.tar.gz: 7c8e625a46c9cb041b948534125b82be649331be
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c188fb3c973efa43ee60f97d275f47383709333524e375b7b85fc7fd16b766bc6f54c04894b0ecac468207925ef46c13d9fdb37dcacd3575356ddff3d1289ecf
|
7
|
+
data.tar.gz: 46fb36af966247aad6d27a54696a8bf9804d2817dadabac9786ec3a98e6aa6e3b8b425c47efcc1a61f6c768f65ff1d44d31ad50fc2730fb9c53d9b8fa8d6530c
|
data/README.md
CHANGED
@@ -1,23 +1,23 @@
|
|
1
1
|
vagrant-phpstorm-tunnel
|
2
|
-
|
2
|
+
=======================
|
3
|
+
`vagrant-phpstorm-tunnel` installs a proxy php binary which can be configured as a php-interpreter in [PhpStorm](http://www.jetbrains.com/phpstorm/).
|
4
|
+
It will forward all php calls to `php` in the [Vagrant](http://www.vagrantup.com/) VM.
|
3
5
|
|
4
|
-
|
6
|
+
This is a workaround for a missing feature in PhpStorm (see http://youtrack.jetbrains.com/issue/WI-19485).
|
5
7
|
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
## Vagrantfile
|
11
|
-
|
12
|
-
```ruby
|
13
|
-
Vagrant.require_plugin "vagrant-phpstorm-tunnel"
|
14
|
-
|
15
|
-
Vagrant.configure("2") do |config|
|
16
|
-
#...
|
17
|
-
end
|
8
|
+
Installation
|
9
|
+
------------
|
10
|
+
```sh
|
11
|
+
vagrant plugin install vagrant-phpstorm-tunnel
|
18
12
|
```
|
19
13
|
|
20
|
-
|
21
|
-
|
22
|
-
`vagrant-phpstorm-tunnel` will create file
|
14
|
+
PhpStorm
|
15
|
+
--------
|
16
|
+
`vagrant-phpstorm-tunnel` will create a file `.idea/vagrant/php` in your vagrant-project.
|
17
|
+
Select this file as a PHP interpreter in PhpStorm:
|
18
|
+
![PhpStorm screenshot](docu/phpstorm-interpreter.png)
|
23
19
|
|
20
|
+
Limitations
|
21
|
+
-----------
|
22
|
+
The plugin assumes your project is shared as `/vagrant` in the VM.
|
23
|
+
It will copy PhpStorm's helper-scripts into `.idea/vagrant/tmp/` to make them accessible from within the VM.
|
data/data/php
CHANGED
@@ -1,54 +1,49 @@
|
|
1
|
-
#!/usr/bin/env php
|
1
|
+
#!/usr/bin/env php
|
2
2
|
<?php
|
3
3
|
|
4
|
-
$
|
5
|
-
|
6
|
-
$
|
7
|
-
$projectTmpDir = '/tmp';
|
8
|
-
|
4
|
+
$projectDir = dirname(dirname(dirname($_SERVER['PHP_SELF'])));
|
5
|
+
$homeDir = $projectDir . '/.idea/vagrant';
|
6
|
+
$tmpDir = $homeDir . '/tmp';
|
9
7
|
$vagrantDir = '/vagrant';
|
10
|
-
$
|
8
|
+
$pipe = 'vagrant ssh -c ';
|
11
9
|
|
12
|
-
|
13
|
-
while(count($pathCrumbs)) {
|
14
|
-
$_path = implode('/', $pathCrumbs);
|
15
|
-
if(is_dir($_path . '/.idea')) {
|
16
|
-
$projectDir = $_path;
|
17
|
-
break;
|
18
|
-
}
|
19
|
-
array_pop($pathCrumbs);
|
20
|
-
}
|
10
|
+
chdir($projectDir);
|
21
11
|
|
22
|
-
|
23
|
-
|
24
|
-
|
12
|
+
// Detect Host IP
|
13
|
+
$hostIpFile = $homeDir . '/host_ip';
|
14
|
+
if (!file_exists($hostIpFile)) {
|
15
|
+
$ip = shell_exec('vagrant ssh -c "sudo ip route | awk \'/default/ { print \$3 }\'"');
|
16
|
+
file_put_contents($hostIpFile, $ip);
|
17
|
+
}
|
18
|
+
$hostIp = trim(file_get_contents($hostIpFile));
|
19
|
+
if (!filter_var($hostIp, FILTER_VALIDATE_IP)) {
|
20
|
+
throw new Exception('Cannot detect host IP, got value `' . $hostIp . '`.');
|
25
21
|
}
|
26
22
|
|
27
|
-
$args = $_SERVER['argv'];
|
28
|
-
foreach ($args as $index => &$arg) {
|
29
23
|
|
24
|
+
$arguments = $argv;
|
25
|
+
array_shift($arguments);
|
26
|
+
foreach ($arguments as $index => &$argument) {
|
30
27
|
// IP mapping
|
31
|
-
$
|
28
|
+
$argument = str_replace(array('127.0.0.1', 'localhost'), $hostIp, $argument);
|
32
29
|
|
33
30
|
// Paths mapping
|
34
|
-
$filePath = $
|
31
|
+
$filePath = $argument;
|
35
32
|
if (file_exists($filePath)) {
|
36
33
|
if (strpos($filePath, $projectDir) !== false) {
|
37
34
|
// Mapping project paths to remote paths
|
38
|
-
$
|
35
|
+
$arguments[$index] = str_replace($projectDir, $vagrantDir, $filePath);
|
39
36
|
} else {
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
$args[$index] = $vagrantDir . $projectTmpDir . '/tunnel.' . $basename;
|
45
|
-
}
|
37
|
+
// Mapping any other local system paths to remote paths, upload files
|
38
|
+
$basename = basename($filePath);
|
39
|
+
copy($filePath, $projectDir . '/' . $tmpDir . '/tunnel.' . $basename);
|
40
|
+
$arguments[$index] = $vagrantDir . '/' . $tmpDir . '/tunnel.' . $basename;
|
46
41
|
}
|
47
42
|
}
|
48
43
|
|
49
|
-
$
|
44
|
+
$argument = escapeshellarg($argument);
|
50
45
|
}
|
51
|
-
|
46
|
+
|
52
47
|
|
53
48
|
// Get XDEBUG environment variable
|
54
49
|
$env = '';
|
@@ -56,15 +51,5 @@ if (isset($_SERVER['XDEBUG_CONFIG'])) {
|
|
56
51
|
$env = "XDEBUG_CONFIG='" . $_SERVER['XDEBUG_CONFIG'] . "'";
|
57
52
|
}
|
58
53
|
|
59
|
-
// Tunnel
|
60
|
-
$pipe = 'vagrant ssh -c ';
|
61
|
-
|
62
|
-
// Remote command
|
63
|
-
$commandRemote = $env . ' php ' . implode(' ', $args);
|
64
|
-
|
65
|
-
// Local command
|
66
|
-
$commandLocal = 'cd ' . $projectDir . ' && ' . $pipe . '"' . $commandRemote . '"';
|
67
|
-
passthru($commandLocal);
|
68
54
|
|
69
|
-
|
70
|
-
?>
|
55
|
+
passthru($pipe . '"' . $env . ' php ' . implode(' ', $arguments) . '"');
|
@@ -1,13 +1,13 @@
|
|
1
1
|
require 'vagrant-phpstorm-tunnel/configurator'
|
2
2
|
|
3
|
-
module
|
4
|
-
class Plugin < Vagrant.plugin(
|
3
|
+
module VagrantPhpstormTunnel
|
4
|
+
class Plugin < Vagrant.plugin('2')
|
5
5
|
|
6
|
-
name
|
6
|
+
name 'vagrant-phpstorm-tunnel'
|
7
7
|
|
8
8
|
%w{up provision}.each do |action|
|
9
|
-
action_hook(:
|
10
|
-
hook.append
|
9
|
+
action_hook(:install_tunnel, "machine_action_#{action}".to_sym) do |hook|
|
10
|
+
hook.append VagrantPhpstormTunnel::Configurator
|
11
11
|
end
|
12
12
|
end
|
13
13
|
|
@@ -1,12 +1,13 @@
|
|
1
1
|
require 'fileutils'
|
2
2
|
|
3
|
-
module
|
3
|
+
module VagrantPhpstormTunnel
|
4
4
|
class Configurator
|
5
5
|
def initialize(app, env)
|
6
6
|
@app = app
|
7
7
|
@env = env
|
8
8
|
|
9
9
|
@root_path = @env[:root_path].to_s
|
10
|
+
@home_path = '.idea/vagrant'
|
10
11
|
end
|
11
12
|
|
12
13
|
def is_intellij
|
@@ -14,25 +15,22 @@ module VagrantPhpStormTunnel
|
|
14
15
|
end
|
15
16
|
|
16
17
|
def link_php_to_intellij
|
17
|
-
destination_path = @root_path
|
18
|
+
destination_path = File.join(@root_path, @home_path, 'php')
|
18
19
|
source_path = File.expand_path('../../../data/php', __FILE__)
|
19
20
|
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
end
|
21
|
+
FileUtils.rm_rf(@home_path)
|
22
|
+
FileUtils.mkdir_p(@home_path)
|
23
|
+
File.link(source_path, destination_path)
|
24
|
+
File.chmod(0755, destination_path)
|
25
25
|
end
|
26
26
|
|
27
27
|
def call(env)
|
28
28
|
@env = env
|
29
29
|
@app.call(env)
|
30
30
|
|
31
|
-
if
|
32
|
-
|
31
|
+
if is_intellij
|
32
|
+
link_php_to_intellij
|
33
33
|
end
|
34
|
-
|
35
|
-
link_php_to_intellij
|
36
34
|
end
|
37
35
|
end
|
38
36
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: vagrant-phpstorm-tunnel
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Cargo Media
|
@@ -16,18 +16,18 @@ dependencies:
|
|
16
16
|
name: rake
|
17
17
|
requirement: !ruby/object:Gem::Requirement
|
18
18
|
requirements:
|
19
|
-
- -
|
19
|
+
- - ">="
|
20
20
|
- !ruby/object:Gem::Version
|
21
21
|
version: '0'
|
22
22
|
type: :development
|
23
23
|
prerelease: false
|
24
24
|
version_requirements: !ruby/object:Gem::Requirement
|
25
25
|
requirements:
|
26
|
-
- -
|
26
|
+
- - ">="
|
27
27
|
- !ruby/object:Gem::Version
|
28
28
|
version: '0'
|
29
|
-
description:
|
30
|
-
|
29
|
+
description: Installs a proxy php binary which can be configured as a php-interpreter
|
30
|
+
in PhpStorm
|
31
31
|
email: hello@cargomedia.ch
|
32
32
|
executables: []
|
33
33
|
extensions: []
|
@@ -35,9 +35,9 @@ extra_rdoc_files: []
|
|
35
35
|
files:
|
36
36
|
- LICENSE
|
37
37
|
- README.md
|
38
|
-
- lib/vagrant-phpstorm-tunnel/configurator.rb
|
39
|
-
- lib/vagrant-phpstorm-tunnel.rb
|
40
38
|
- data/php
|
39
|
+
- lib/vagrant-phpstorm-tunnel.rb
|
40
|
+
- lib/vagrant-phpstorm-tunnel/configurator.rb
|
41
41
|
homepage: https://github.com/cargomedia/vagrant-phpstorm-tunnel
|
42
42
|
licenses:
|
43
43
|
- MIT
|
@@ -48,18 +48,18 @@ require_paths:
|
|
48
48
|
- lib
|
49
49
|
required_ruby_version: !ruby/object:Gem::Requirement
|
50
50
|
requirements:
|
51
|
-
- -
|
51
|
+
- - ">="
|
52
52
|
- !ruby/object:Gem::Version
|
53
53
|
version: '0'
|
54
54
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
55
55
|
requirements:
|
56
|
-
- -
|
56
|
+
- - ">="
|
57
57
|
- !ruby/object:Gem::Version
|
58
58
|
version: '0'
|
59
59
|
requirements: []
|
60
60
|
rubyforge_project:
|
61
|
-
rubygems_version: 2.
|
61
|
+
rubygems_version: 2.2.2
|
62
62
|
signing_key:
|
63
63
|
specification_version: 4
|
64
|
-
summary: PhpStorm
|
64
|
+
summary: Proxy php-calls from PhpStorm to Vagrant
|
65
65
|
test_files: []
|