Using a Docker Container as a PHP Interpreter

Hi, 

I created a named in '/usr/local/bin/php7' with these contents:

---

#!/bin/bash
docker run -it --rm -v "$PWD":/usr/src/myapp -w /usr/src/myapp -u $UID:${GROUPS[0]} byjg/php7 php "$@"

---

After I tried to create a new interpreter and I got the message "PHP Is not installed". 

 

1
Avatar
Permanently deleted user

Hello,

We do not support such configurations.

Please follow these steps to configure a remote PHP interpreter inside Docker:

https://confluence.jetbrains.com/display/PhpStorm/Docker+Support+in+PhpStorm - complete Docker integration configuration guide
* https://blog.jetbrains.com/phpstorm/2016/11/docker-remote-interpreters/ - adding remote Docker interpreter into PhpStorm

0

Hi Vladmir, 

This was useful for me. I follow the guide "Docker Remote Interpreters" but when I am checking the PHP version I got:

Can not update phpinfo: Cannot parse configuration file

 

0

Please try to provide a full path to PHP executable there.

0

I reinstalled the PHPStorm and followed the instructions and It worked. 

Thank you. 

0
Avatar
Permanently deleted user

Joao, 

why did you need to reinstall phpstorm for this to work? I am having the same problem as you had with the phpinfo popup, but I just installed phpstorm a few weeks ago, so I am wondering what this fixes, or whether its just a coincidence?

0

Well, 

When I wrote this post, I had upgraded my PHPStorm from 2016.2 to 2016.3. 

After I removed the PHPStorm and get a fresh install with no previous config (removed the ~/.PHPStorm2016.3 folder) and I did a new setup everything works. 

I do not know exactly what I did wrong previously. 

0
Avatar
Permanently deleted user

JetBrains - this is probably a common request as most people want to run their tests on the production environment described in their docker-composer.xml, not in php:cli image spun up by PhpStorm.

 

Joao, and others, the reason the above script didn't work is because PhpStorm calls the php interpreter with /tmp/ide-phpinfo.php as a parameter.

Simplest fix would be to map host machine's /tmp to container's /tmp, but that seems dangerous and ugly.

Another possibility is processing the arguments sent to your "php interpreter", strip out and copy any files referencing /tmp, and modify all arguments to point the copied location.

I'll post more on this one if there's any interest.

1

Hi Greg, 

I solved my problem on this post before without know this.

BUT what you said was very important for me. I mapped my /tmp to docker's /tmp and I believe some problems I had can be solved :)

Thank you!

0

请先登录再写评论。