Setup php interpreter from docker via ssh

I have local network with 2 computers: windows laptop with phpstorm and ubuntu dev server. On server I got docker-compose with php-fpm image.

Can you please tell me how to configure the interpreter for this setup?

 

I add docker deamon connection via ssh and get success.

 

First try:

Add remote interpreter from docker:

Got volume error:

What is this value and how i can fix it? They are not in the docker-compose.yml

 

Second try:

Add remote interpreter from docker compose:

Got parse error

I sopose, that phpstorm run docker compose from windows laptop, not via ssh.

If drop docker executable path from Docker->Tools

Got this error: 

So, there should be path from ssh host

But I can specify only local path here...

Thanks in advance for help

0

Unfortunately, remote Docker interpreters are not supported: https://youtrack.jetbrains.com/issue/IDEA-272627

0

Ok, I got the solution.

General idea: make phpstorm think that the remote ssh host got php-fpm server on it, while real php-fpm server run inside docker container.

I've got next setup:

192.168.1.204 - work station with windows and phpstorm

192.168.1.28 - local dev server with ubuntu and docker

docker: php-fpm (container name: sandbox4-php)

 

1. Create executable file /usr/bin/php-sandbox to redirect all php calls to docker container

#! /bin/bash

docker exec sandbox4-php /usr/local/bin/php "$@"

2. Сhange all file paths in the docker container to match the paths on the dev server (docker-compose.yml, Dockerfile, nginx.conf)

My path to project root: /var/projects/sandbox4

3. Throw volume from /home/$user/.phpstorm_helpers to same path on container

Without this step phpsorm can't parse response from interpreter

4. Setup ssh iterpreter

PHP executable should be gateway to docker: /usr/bin/php-sandbox

5. Configure debugger - this step I still fail. 

I setup phpstorm to see php.ini file with this settings, but phpstorm still call debugger  with default setting:

I solve thi problem another way

6. Config debug server with mappings

7. To run php with xdebug all the time, I add environment variables to docker-compose.yml

XDEBUG_SESSION: 1

PHP_IDE_CONFIG: serverName=dev

8. Add run configuration, nothing special

9. PROFIT! :)

 

Limitations: ofcourse, this config will work only in local network. To run this for remote server need VPN, but i'm fine with that.

If anyone has solution to normal configure debug run in phpstorm - pls, share. I'm put up with every run - is debug run, so far.

 

PS. OMG, phpstorm is realy painfull for setup...

 

0

请先登录再写评论。