L
L
l4m3r2019-03-12 20:23:20
phpstorm
l4m3r, 2019-03-12 20:23:20

How well is Docker integrated into PhpStorm?

As I understand it, the same convenient integration into the IDE, as with local php + node, is there no software?
1) php + xdebug started up just with a huge tambourine and garbage in docker-compose.
2) node, as I understand it, will not work at all, so that the npm tab appears with a list of commands from package. And in general, you can forget about any browsersync.
3) The Docker tab only allows you to start/restart/delete containers and images.
Develop the project only by operating in the terminal with the commands docker-compose exec npm watch / docker-compose exec php artisan make:XXX / docker-compose exec php composer require? Or can they be reduced in some way? It was smart enough to just add alias artisan="docker-compose exec php" to bashrc, but this is so-so kmk.
PS: yes, I asked a similar question. But there I described everything crookedly.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
M
Maxim Fedorov, 2019-03-12
@l4m3r

You can call make
Especially when you need to group several commands
Here is an example, unfortunately someone else's, I still don’t get my hands on Docker properly, Vagrant still covers everything
Example Makefile
Works in Linux like this: make {command}
And then look how many commands make init executes :)

R
Roman Dubinin, 2019-06-04
@romash

About xdebug, I can say that you are most likely preparing something wrong. It is important to understand that xdebug itself is essentially a client that sends data to the debug server (in this case, it is picked up by PHPStorm). Based on this, we can confidently state that there should be nothing related to debugging in docker-compose at all (the maximum can be attributed here is forwarding the vendor folder, if you need to go through the libraries loaded by the composer in debugging).
How xdebug works: you open a page in the browser, php starts processing it, xdebug looks at its config and, if it sees the connection information (address and port of the debug server), then connects to it, learns about breakpoints and then they interact with each other , but the connection is raised by php, that is, it goes from the container to the host, no ports need to be forwarded, since your host is always visible from the container.
I put in the config xdebug.remote_connect_back=on, then you do not need to specify it xdebug.remote_hostand it looks for the server on the ip from which the page was opened. True, you can’t debug cli in this way, but you can also get the host’s ip-shnik somehow, you can google it if you really want to.
Let's say you have the following written in xdebug.ini:

zend_extension=xdebug.so
xdebug.remote_enable=on
xdebug.remote_autostart=on
xdebug.remote_connect_back=on
xdebug.remote_port=9999

Then in PHPStorm it is enough:
In the Xdebug section, specify port 9999 and check the box Can accept external connections .
At the very bottom, Advanced settingsuncheck Notify if debug session was finished without being paused
Add server:
Name and Host from server_namenginx (I did not configure other proxies)
Port is also from the nginx config, and not the one that is forwarded to the outside!
PHP takes this data from its proxy inside the container and transmits it when raising the debug session, so if you specify it incorrectly, Path mapping will not work.
Checkbox Use path mappings and match the project folder with an absolute path inside the container
Also, just in case and for comparison, instructions for VSCode:
Install the PHP Debug extension and add the following to the debug configuration
{
    "name": "Listen for XDebug in Docker",
    "type": "php",
    "request": "launch",
    "port": 9999,
    "pathMappings": {
        "Абсолютный путь к папке проекта в контейнере": "${workspaceRoot}"
    }
}

This thing works fine for me from under Windows with the old docker-machine, and I would not call it a "huge tambourine" ...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question