I am trying to make PHPstan work for a dockerized Symfony project using this template. The project use PHP 8.1.16. Works fine.
Now I want to push it a little bit to fully use the PHP CLI installed in my docker container instead of the local one.
I followed this tutorial to make PhpStorm use the PHP CLI installed in my docker container. Then configured PHPstan and PHP CS Fixer to use this CLI.
Everything is detected fine but PHPstan can't make use of the path provided for container_xml_path
in phpstan.neon
.
Here is my phpstan.neon
:
includes:
- vendor/phpstan/phpstan-doctrine/extension.neon
- vendor/phpstan/phpstan-doctrine/rules.neon
- vendor/phpstan/phpstan-symfony/extension.neon
- vendor/phpstan/phpstan-symfony/rules.neon
- vendor/phpstan/phpstan-phpunit/extension.neon
- vendor/phpstan/phpstan-phpunit/rules.neon
- vendor/phpstan/phpstan-strict-rules/rules.neon
- vendor/phpstan/phpstan-deprecation-rules/rules.neon
parameters:
symfony:
container_xml_path: var/cache/dev/App_KernelDevDebugContainer.xml
console_application_loader: bin/console
consoleApplicationLoader: tests/console-application.php
level: 9
paths:
- src
- tests
And this is the error I get when PHPstan automatically run :
The file path is okay, but the file only exist in the container, my local var
dir is empty.
Is that the problem or am I missing the point? And how can I link it properly?
I got it. What was missing is the "Connect to existing container ('docker-compose exec') ." step described here I wasn't able to see it because i choose "Docker" over "Docker compose" in the dialog box step 5 of this tutorial.
Also, if someone struggle with a similar problem, make sure you use correct docker version (docker-compose
or the latest docker compose
).
To use the new docker compose
, check the box "Use Compose V2 (beta)" under Settings Build, Execution, Deployment > Docker > Tools.