Open Swader opened 9 years ago
Btw. referencing something relatively to the kernel root dir is the symfony way. This is a standard edition and if you need to change the vendor dir to another layout beside the normal composer layout and change your config files accordingly.
Because if you created your project based on the standard edition, you can modify it, it's your code now, the app config is not a vendor code :)
I see. Well, if that's convention, maybe add a section to the docs explaining what needs to be done, in addition to the Symfony guide, to move the vendor folder?
Although this is the symfony way, I didn't really liked that from the beginning. Using ..
in a path feels a bit strange to me, since it is coupling even more. I would prefer the solution with an own variable containing the path to the vendor
directory. Makes this procedure a lot easier, and al these paths easier to read. /cc @chirimoya
@danrot So @Swader way with detecting the vendor path in the composer.json via compiler pass and set a paramter into the container (e.g. %sulu.vendor_dir%) is surely a nice idea.
@patkar The only problem is, that you can only use that for the configuration files. For the compiler pass the autoloading already has to be working, so two places to adapt will remain.
Yes, but the place to adapt the autoloader path in the autoload.php is already documented by Symfony in the part, where to change the vendor path: http://symfony.com/doc/current/cookbook/configuration/override_dir_structure.html#override-the-vendor-directory
I have created a small shell script which takes care of this automatically. After installing Sulu, running the script will, in order:
sulu.yml
with new valuescomposer install
to apply these changesvendor
from current folderThis will be relatively fast because all the packages will already be in the cache from installing on the first run. This can help tide things over until you figure out how to put all this into a config variable. I'll include the instructions for this script in my tutorial.
Ok, I think it might be possible that we have solved that issue before you publish your article. In that case you'll be notified of course.
Excellent, let me know. I'd prefer if it didn't have to be used as it's obviously quite hacky.
Tried to fix that in https://github.com/sulu-io/sulu/pull/1721, but there is a problem with another extension. Hopefully I find some time to look into this deeper quite soon.
Symfony makes is relatively easy to switch out the vendor location. See here.
However, Sulu adds some hardcoded locations:
This should be rectified.
Suggested solution: read vendor directory location from
composer.json
and set in all three locations -autoload.php
and the above two files.