Closed bobvandevijver closed 10 years ago
@bobvandevijver it seems that instead of kernel.root_dir
it uses kernel.cache_dir
/var/www/dev/app/cache/dev/..
+/src
<-- this resolves to/var/www/dev/app/cache
+/src
which is the cache dir +/src
And actually it should be:
/var/www/dev/src
, as kernel root dir/var/www/dev
+/src
However, this part of code has been for 3 years already see blame log and it looks OK to me, so there probably is something terribly wrong with your config.
@loostro I have found the cause of the problem, and it lies in with the usage of the dirname function.
Somehow, the kernel.root_dir
param returns /var/www/dev/app/cache/dev/../../
, which is, as you can see completely correct. It resolves to the kernel root dir. However, the function dirname()
calculates the parent directory (as stated in the PHP docs http://us3.php.net/manual/en/function.dirname.php).
When used on a path with ../
, it just removes the latter and effectively calculates the wrong dir! The reason why kernel.root_dir
contains the cache path with ../../
is not clear to me, but it might have something to do with the console environment. The parameter is the real root dir when requesting it in a controller.
Examples:
echo dirname("/var/www/dev/app/cache/dev/../..").'/src'; <-- Generated in console
echo dirname("/var/www/dev/app/").'/src'; <-- Expected behaviour in console
Output:
/var/www/dev/app/cache/dev/../src
/var/www/dev/src
I think that it is completely valid to rewrite the line without the usage of dirname. As it is still something a user can put in/change, the use of just kernel.root_dir
and ../src
should be completely valid. I can create a PR for this, so that nobody should ever suffer if the same happens with their environment.
Fixed on all branches by #766, #767, #768.
Somehow, line 93 (https://github.com/symfony2admingenerator/AdmingeneratorGeneratorBundle/blob/master/Command/GenerateAdminAdminCommand.php#L93) of the `admin:generate-admin' generates the wrong dir path and the new structure is placed in the cache dir: not what I want.
The dir that is generated:
/var/www/dev/app/cache/dev/../src
The dir that is needed:
/var/www/dev/app/cache/dev/../../../src
I've solved it by changing the line to
$dir = $input->getOption('dir') ?: $this->getContainer()->getParameter('kernel.root_dir') . '/../src';
, so by removing the dirname function and adding extra/..
. For some strange reason it does not work with the dirname command.