提问人:j0nnybrav0 提问时间:11/10/2023 最后编辑:yivij0nnybrav0 更新时间:11/10/2023 访问量:19
symfony,var-folder 作为符号链接,由于错误的供应商包含,在 Apache 上不起作用
symfony, var-folder as symlink does not work on apache due to wrong vendor-includes
问:
我有一个空的symfony,通过composer.json安装,包括apache-pack和api-platform(见下面的文件)。
环境
我们需要提供 var-folder 作为符号链接。
- 应用文件夹:/app
- var 文件夹:/contents/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-path,一切都会好起来的: /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可以解决问题,但是:
如果 app-root-cache 是 /var/www/api/var/cache
APP_CACHE_DIR = /var/contents/api/var/cache ->error
将不起作用,因为最后三个文件夹“api/var/cache”是相同的。 如果将缓存重命名为 appcache 或其他名称,则它可以正常工作。
APP_CACHE_DIR = /var/contents/api/var/appcache ->success
评论