I have an empty symfony, installed via composer.json, apache-pack and api-platform included (see file below).
Environment
We need to offer the var-folder as a symlink.
- App-Folder: /app
- Var-Folder: /contents/var
The app-folder structure results in:
[...]
templates
var -> /contents/var
vendor
Problem
Symfony creates classes in var/cache, which include vendor-classes like this:
include_once dirname(__DIR__, 4).'/vendor/symfony/kernel/ErrorHandler.php';
The problem is, that __ DIR __ returns the source-path of the symlink, not the target app-path, so the class cannot be found:
Warning: include_once(/contents/vendor/symfony/kernel/ErrorHandler.php): Failed to open stream: No such file or directory
So it says vendor is in
/contents/vendor instead of
/app/vendor
If DIR would return the app-path, everything would be fine:
/app/vendor/symfony/kernel/ErrorHandler.php
Question
Does anybody know how to solve this? It is NOT possible to change the environment due to a gitlab-setup which can’t be changed by us.
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.*"
}
}
}