Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Setting up remote interpreter in PHPStorm - documentation #951

Closed
benkelukas opened this issue May 18, 2017 · 9 comments
Closed

Setting up remote interpreter in PHPStorm - documentation #951

benkelukas opened this issue May 18, 2017 · 9 comments

Comments

@benkelukas
Copy link

Info:

  • Docker version ($ docker --version): Docker version 17.03.1-ce, build c6d412e
  • Laradock commit ($ git rev-parse HEAD): b9b9d52
  • System info (Mac, PC, Linux): Linux
  • System info disto/version: Ubuntu 17.0.4

Issue:

Hello, this is not issue per se, but after 4 hours of fiddling around, I've finally been able to correctly setup remote interpreter on Ubuntu 17.04 - including finding docker host ip, setting WORKSPACE_INSTALL_WORKSPACE_SSH to TRUE (ha, that one was nasty), correcting permissions on workspace/insecure_id_rsa etc. I'm willing to document this process and send pull request with updated documentation, my question is, if you are interested in this.

FOR ANYONE COMING HERE
Process is as follows:

Find your Docker Host IP

Open terminal, run ifconfig and look for docker0 interface, note the IP address. Example output:
docker0: flags=4099<UP,BROADCAST,MULTICAST> mtu 1500 inet === IP IS HERE => 172.17.0.1 netmask 255.255.0.0 broadcast 0.0.0.0 inet6 fe80::42:7aff:fe74:e3dc prefixlen 64 scopeid 0x20<link> ether 02:42:7a:74:e3:dc txqueuelen 0 (Ethernet) RX packets 19980 bytes 1627092 (1.6 MB) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 25136 bytes 34818849 (34.8 MB) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0

Enable SSH in workspace

set WORKSPACE_INSTALL_WORKSPACE_SSH to true: WORKSPACE_INSTALL_WORKSPACE_SSH=true this is important, otherwise, you will get connection refused error

Set found Docker Host IP

set DOCKER_HOST_IP variable to found ip in .env :
DOCKER_HOST_IP=${FOUND_IP} //e.g. 172.17.0.1

Fix permissions on ssh keys

For me, the pregenerated .ppk files were not working (corrupted format error message in PHPStorm), so i used the ${LARADOCK_FOLDER}/workspace/insecure_id_rsa, but before you can do that, you need to fix the permissions, othwerwise, they will get ignored by ssh. They should be 0600. You can do that with following command:
chmod 0600 ${LARADOCK_FOLDER}/workspace/insecure_id_rsa

Set up deployment in PHPStorm

In PHPStorm, go to Settings -> Build, Execution, Deployment add a new SFTP deployment. Set it as follows:

  • SFTP host: ${FOUND_IP} - e.g. 172.17.0.1
  • Port: 2222 (can be found in laradock .env - )
  • Root path: /var/www
  • User name: root
  • Auth type: Key pair
  • private key file: ${LARADOCK_FOLDER}/workspace/insecure_id_rsa
    Click Test SFTP Connection - should work.

Set up the remote interpreter in PHPStorm

  • Go to Settings -> Languages & Frameworks -> PHP
  • click on three dots next to CLI Interpreter
  • add a new one, select From docker, vagrant, remote, ..
  • select deployment configuration - and select the previously configured deployment
  • click OK

You should be all set

@chrishodgson
Copy link

chrishodgson commented Aug 11, 2017

Hi
I'm struggling to find the DOCKER_HOST IP

docker ps -a returns several active containers including laradockstoryboard_workspace. When i type ifconfig docker0 from OSX command line it returns an error ifconfig: interface docker0 does not exist

The env-example file already has the DOCKER_HOST_IP set to 10.0.75.1 but this doesn't work when I add it to a deployment in PHPStorm
thanks
chris

@benkelukas
Copy link
Author

benkelukas commented Aug 11, 2017 via email

@mpoiriert
Copy link

I follow the procedure to the letter and everything worked.

I did want to configure PHPUnit to run trough the editor so there is a few extra step.

Languages & Frmeworks > PHP
Add the path mappings from your root project to /var/www on the remote machine

Languages & Frmeworks > PHP > test Frmeworks
Add PHPUnit by remote interpreter
PHPUnit library Use Composer Autoloader
Path to script: /var/www/vendor/autoloader.php

Enjoy !

@jerfeson
Copy link

@mpoiriert Amazing, worked for me

@zlanich
Copy link

zlanich commented May 9, 2018

This article was helpful to me too: http://webandapp.fr/blog/2017/09/where-is-my-database-host/

After updating Docker recently, by "Docker" setting in PHPStorm no longer worked and I realized that the docker-compose setting is supposedly the preferred one and works.

@daniel-farina
Copy link

This is useful for Mac users:
https://www.youtube.com/watch?time_continue=50&v=bWbXMy_mxxE

@Olnyov
Copy link

Olnyov commented Jan 17, 2020

My solution:

laradock/.env

  • Dont change DOCKER_HOST_IP=...,
  • Dont change WORKSPACE_INSTALL_WORKSPACE_SSH,
  • Run laradock containers.

PhpStorm settings:

  • Go to File -> Settings -> Languages &Frameworks -> PHP,
  • Click on ... CLI interpreter button,
  • Add new interpreter (click + button) From Docker, Vagrant, ...,
  • Check radio button Docker,
  • Select on Image name laradock php-fpm container. PhpStorm must to define PHP version,
  • Click Apply,
  • Next you want to define PHPUnit. Go to File -> Settings -> Languages &Frameworks -> PHP -> TestFrameworks,
  • Add new configuration PHPUnit by remote interpreter,
  • Select on CLI Interpreter laradock php-fpm interpreter,
  • Path mappings and Docker container fields will autocomlete,
  • Complete test runner fields, if you need.
  • In PhpUnit Library i use composer autoloader (for example: /opt/project/vendor/autoload.php, becouse i download PHPUnit by composer),
  • Click Apply,
  • Go to Run -> Edit configuration,
  • Add new configuration PHPUnit,
  • Select on Interpreter field - Default project interpreter

@stale
Copy link

stale bot commented Apr 16, 2020

Hi 👋 this issue has been automatically marked as stale 📌 because it has not had recent activity 😴. It will be closed if no further activity occurs. Thank you for your contributions ❤️.

@stale stale bot added the Stale label Apr 16, 2020
@stale
Copy link

stale bot commented May 7, 2020

Hi again 👋 we would like to inform you that this issue has been automatically closed 🔒 because it had not recent activity during the stale period. We really really appreciate your contributions, and looking forward for more in the future 🎈.

@stale stale bot closed this as completed May 7, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

8 participants