sulu / sulu-standard

This repository is not longer the recommended way to start a sulu project. Use:
https://github.com/sulu/skeleton
MIT License
613 stars 106 forks source link

Vendor hardcoded #542

Open Swader opened 9 years ago

Swader commented 9 years ago

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.

QuingKhaos commented 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 :)

Swader commented 9 years ago

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?

danrot commented 9 years ago

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

QuingKhaos commented 9 years ago

@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.

danrot commented 9 years ago

@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.

QuingKhaos commented 9 years ago

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

Swader commented 9 years ago

I have created a small shell script which takes care of this automatically. After installing Sulu, running the script will, in order:

This 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.

danrot commented 9 years ago

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.

Swader commented 9 years ago

Excellent, let me know. I'd prefer if it didn't have to be used as it's obviously quite hacky.

danrot commented 9 years ago

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.