我有一个空的symfony,通过composer.json安装,包含apache-pack和api-platform(参见下面的文件)。
环境
我们需要提供 var 文件夹作为符号链接。
应用程序文件夹结构导致:
[...]
templates
var -> /contents/var
vendor
问题
Symfony 在 var/cache 中创建类,其中包括如下所示的供应商类:
include_once \dirname(__DIR__, 4).'/vendor/symfony/kernel/ErrorHandler.php';
问题是, __ DIR __ 返回符号链接的源路径,而不是目标应用程序路径,因此找不到该类:
警告:include_once(/contents/vendor/symfony/kernel/ErrorHandler.php):无法打开流:没有这样的文件或目录
所以它说供应商在 /contents/vendor 而不是 /应用程序/供应商
如果 DIR 返回应用程序路径,一切都会好起来的: /app/vendor/symfony/kernel/ErrorHandler.php
问题
有人知道如何解决这个问题吗?由于我们无法更改 gitlab-setup,因此无法更改环境。
composer.json
{
"type": "project",
"license": "proprietary",
"minimum-stability": "stable",
"prefer-stable": true,
"require": {
"php": ">=8.1",
"ext-ctype": "*",
"ext-iconv": "*",
"api-platform/core": "^3.2",
"doctrine/doctrine-bundle": "^2.10",
"doctrine/doctrine-migrations-bundle": "^3.2",
"doctrine/orm": "^2.16",
"nelmio/cors-bundle": "^2.3",
"phpdocumentor/reflection-docblock": "^5.3",
"phpstan/phpdoc-parser": "^1.24",
"symfony/apache-pack": "^1.0",
"symfony/asset": "6.3.*",
"symfony/console": "6.3.*",
"symfony/dotenv": "6.3.*",
"symfony/expression-language": "6.3.*",
"symfony/flex": "^2",
"symfony/framework-bundle": "6.3.*",
"symfony/property-access": "6.3.*",
"symfony/property-info": "6.3.*",
"symfony/runtime": "6.3.*",
"symfony/security-bundle": "6.3.*",
"symfony/serializer": "6.3.*",
"symfony/twig-bundle": "6.3.*",
"symfony/validator": "6.3.*",
"symfony/yaml": "6.3.*"
},
"require-dev": {
"symfony/maker-bundle": "^1.51"
},
"config": {
"allow-plugins": {
"php-http/discovery": true,
"symfony/flex": true,
"symfony/runtime": true
},
"sort-packages": true
},
"autoload": {
"psr-4": {
"App\\": "src/"
}
},
"autoload-dev": {
"psr-4": {
"App\\Tests\\": "tests/"
}
},
"replace": {
"symfony/polyfill-ctype": "*",
"symfony/polyfill-iconv": "*",
"symfony/polyfill-php72": "*",
"symfony/polyfill-php73": "*",
"symfony/polyfill-php74": "*",
"symfony/polyfill-php80": "*",
"symfony/polyfill-php81": "*"
},
"scripts": {
"auto-scripts": {
"cache:clear": "symfony-cmd",
"assets:install %PUBLIC_DIR%": "symfony-cmd"
},
"post-install-cmd": [
"@auto-scripts"
],
"post-update-cmd": [
"@auto-scripts"
]
},
"conflict": {
"symfony/symfony": "*"
},
"extra": {
"symfony": {
"allow-contrib": "true",
"require": "6.3.*"
}
}
}
好吧,在这种情况下,它有点太神奇了。 设置 server-var APP_CACHE_DIR 可以解决问题,但是:
如果应用程序根缓存是例如 /var/www/api/var/cache
APP_CACHE_DIR = /var/contents/api/var/cache -> 错误
不起作用,因为最后三个文件夹“api/var/cache”是相同的。 如果您将缓存重命名为 appcache 或其他名称,它就可以工作。
APP_CACHE_DIR = /var/contents/api/var/appcache ->成功