-
Notifications
You must be signed in to change notification settings - Fork 1
PHP Storm integration PHP
Use droxy to integrate a custom PHP version into PHP Storm.
Assuming you have a custom PHP image like this one:
FROM php:7.2
RUN yes | pecl install xdebug \
&& echo "zend_extension=$(find /usr/local/lib/php/extensions/ -name xdebug.so)" > /usr/local/etc/php/conf.d/xdebug.ini \
&& echo "xdebug.remote_enable=on" >> /usr/local/etc/php/conf.d/xdebug.ini \
&& echo "xdebug.remote_autostart=off" >> /usr/local/etc/php/conf.d/xdebug.ini
ENTRYPOINT ["php"]
You can use droxy to create a custom php command and integrate it into PHP Storm.
Version="1"
[[command]]
name="php7.2"
image="php7.2"
removeContainer=true
volumes=[
"/tmp:/tmp",
"/home/project_dir:/home/project_dir"
]
replaceArgs=[
[
"-dxdebug.remote_host=127.0.0.1",
"-dxdebug.remote_host=172.17.0.1",
]
]
envvars=[
"XDEBUG_CONFIG=${XDEBUG_CONFIG}"
]
Explanation:
You need to map /tmp and your project dir into the container, using volumes.
PHPStorm will try to access a helper script in /tmp to determine php settings.
The Projects dir must be map to give your container access to the projects source.
For debugging you must replace "127.0.0.1" with your host machines docker ip.
This is done in replaceArgs
To determine your docker ip, you can execute sth like: ifconfig docker0 | grep 'inet addr:' | cut -d: -f2 | awk '{ print $1}'
In my case it was: 172.17.0.1
Finally map environment variable XDEBUG_CONFIG into the container since xdebug needs to know the IDE_KEY which is passed in this env var.
With this configuration you can run and debug PHP Scripts from PHPStorm in a docker container.