带有 gitlab-ci 的 Phpstan 找不到 srcApp_KernelDevDebugContainer.xml 因为它在 gitignore 中?
Phpstan with gitlab-ci cant find srcApp_KernelDevDebugContainer.xml because its in the gitignore?
这是我的 phpstan.neon
parameters:
checkMissingIterableValueType: false
checkGenericClassInNonGenericObjectType: false
symfony:
container_xml_path: '%rootDir%/../../../var/cache/dev/srcApp_KernelDevDebugContainer.xml'
bootstrap: '%rootDir%/../../../vendor/autoload.php'
这是我的 gitlab-ci 片段
commit:
stage: analysis
variables:
APP_ENV: dev
cache:
untracked: true
paths:
- Source/var/cache/dev/
before_script:
- cd Source
- cp .env.example .env
- composer install --no-interaction --optimize-autoloader --classmap-authoritative
script:
- composer commit
only:
- merge_requests
我收到以下错误:
In XmlServiceMapFactory.php line 29:
[PHPStan\Symfony\XmlContainerNotExistsException]
Container /builds/Mehlichmeyer/heracles-mvp-symfony/Source/vendor/phpstan/p
hpstan/../../../var/cache/dev/srcApp_KernelDevDebugContainer.xml does not e
xist
问题是我的 gitlab-ci 容器没有 srcApp_KernelDevDebugContainer.xml,因为它在我的 .gitignore(/var/ 是)中。任何解决方法的想法?
要获得此文件,您必须在激活调试的情况下为开发环境生成缓存。我想这可以在 "before_script" 部分完成:
before_script:
- cd Source
- cp .env.example .env
- composer install --no-interaction --optimize-autoloader --classmap-authoritative
- php bin/console cache:warmup --env=dev
您的 .env
文件必须具有调试标志:
###> symfony/framework-bundle ###
APP_ENV=dev
APP_DEBUG=1
APP_SECRET=APP_SECRET
###< symfony/framework-bundle ###
我不知道 gitlab-ci 但我用 github-actions 做了这个并且效果很好。
好吧,我终于找到问题了。我将我的 Symfony 从 4.x 更新到 5.x,我不得不调整我的 phpstan.neon
container_xml_path: '%rootDir%/../../../var/cache/dev/App_KernelDevDebugContainer.xml'
本地这从来没有抛出错误,因为我没有 运行 bin/console cache:clear,所以旧的 container_xml_path 工作正常。
这是我的 phpstan.neon
parameters:
checkMissingIterableValueType: false
checkGenericClassInNonGenericObjectType: false
symfony:
container_xml_path: '%rootDir%/../../../var/cache/dev/srcApp_KernelDevDebugContainer.xml'
bootstrap: '%rootDir%/../../../vendor/autoload.php'
这是我的 gitlab-ci 片段
commit:
stage: analysis
variables:
APP_ENV: dev
cache:
untracked: true
paths:
- Source/var/cache/dev/
before_script:
- cd Source
- cp .env.example .env
- composer install --no-interaction --optimize-autoloader --classmap-authoritative
script:
- composer commit
only:
- merge_requests
我收到以下错误:
In XmlServiceMapFactory.php line 29:
[PHPStan\Symfony\XmlContainerNotExistsException]
Container /builds/Mehlichmeyer/heracles-mvp-symfony/Source/vendor/phpstan/p
hpstan/../../../var/cache/dev/srcApp_KernelDevDebugContainer.xml does not e
xist
问题是我的 gitlab-ci 容器没有 srcApp_KernelDevDebugContainer.xml,因为它在我的 .gitignore(/var/ 是)中。任何解决方法的想法?
要获得此文件,您必须在激活调试的情况下为开发环境生成缓存。我想这可以在 "before_script" 部分完成:
before_script:
- cd Source
- cp .env.example .env
- composer install --no-interaction --optimize-autoloader --classmap-authoritative
- php bin/console cache:warmup --env=dev
您的 .env
文件必须具有调试标志:
###> symfony/framework-bundle ###
APP_ENV=dev
APP_DEBUG=1
APP_SECRET=APP_SECRET
###< symfony/framework-bundle ###
我不知道 gitlab-ci 但我用 github-actions 做了这个并且效果很好。
好吧,我终于找到问题了。我将我的 Symfony 从 4.x 更新到 5.x,我不得不调整我的 phpstan.neon
container_xml_path: '%rootDir%/../../../var/cache/dev/App_KernelDevDebugContainer.xml'
本地这从来没有抛出错误,因为我没有 运行 bin/console cache:clear,所以旧的 container_xml_path 工作正常。