The rewritten title is: Configuring PHPUnit database using PhpStorm Docker
P粉111641966
P粉111641966 2023-11-01 20:53:17
0
1
789


  • I set up PhpStorm using Docker: PHP, PHPUnit
  • I see the schema in PhpStorm/Database Viewer
  • I can use the database in my application: registration etc.
  • I can run phpunit in PhpStorm
  • But if I want to use the database in my test, I get the following error:

Illuminate database QueryException: SQLSTATE[HY000] [2002] php_network_getaddresses: getaddrinfo failed: name cannot be resolved (SQL: select * from Table name)

The tests run in the container but are broken in the IDE. Do you know what the problem is in PhpStorm?

P粉111641966
P粉111641966

reply all(1)
P粉154798196

I encountered this problem. Assuming you've set up a Docker container and a PHP interpreter, this is how I connected to the MySQL container:

  1. Run docker network ls from the CLI and see the "lighthouse_default" network
  2. Go to PHP > Test Framework and edit on my Docker container (click on the folder)
  3. Set network mode to "lighthouse_default"
  4. Add lighthouse_mysql_1 image to Links section

Obviously the network name may be different in your case. The real point is that I have to make sure I'm using the correct network and make sure the database image is in the container link.

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template