TYPO3 / CmsComposerInstallers

TYPO3 CMS Composer Installer
GNU General Public License v2.0
58 stars 39 forks source link

web-dir setting via composer --> what to do if there are multiple servers with different directory? #65

Closed AndreasA closed 7 years ago

AndreasA commented 7 years ago

The web-dir settin makes sense as it allows one to move vendor and bin directory outside the document root. However, what if one has multiple servers that require a different web-dir? It would be nice if one could override that setting via command line argument or similar.

helhum commented 7 years ago

Thanks for your suggestion.

However, what if one has multiple servers that require a different web-dir

What about creating a symlink to such web-dirs in your deployment scripts?

AndreasA commented 7 years ago

You mean like deploying the script e.g. to xxx/web where that folder then points to a the real web directory? That link could then be removed after deployment (but could also be kept). However, this only works if one has the corresponding server permissions.

If so, I would also have to modify the autoload.php link inside typo3_src/vendor/ to the corresponding vendor directory. Not sure, if there would be any other issues.

Being able to override the setting via CLI would be way simpler :)

helhum commented 7 years ago

Being able to override the setting via CLI would be way simpler

Maybe for you :-P

I tend to close this request. It seems like adding code to support an edge case which can be solved differently and which isn't widely required

AndreasA commented 7 years ago

Is it really such an edge case? Personally, I think that you have ONE web directory is the edge case. I already require different settings here, if I have a local development installation that has a different web directory then the server. Especially, if I don't have much influence at the server, e.g. shared web server with only FTP access. Also when using typo3_console one also has to modify the corresponding environment variables to get it to work.

Of course, that is just my opinion, one can solve this issue with modifying the deployment accordingly.

This wasn't an issue with web-dir being not required, one just needed to put everything in the document-root. Of course, one can still use the composer installers that way but there is a reason why it is recommended to use it now.

bmack commented 7 years ago

Hey Andreas,

you can set the web-dir to "" and achieve the same as before, right?

AndreasA commented 7 years ago

Yes, but you get a warning / notification to use web-dir. Also the README.md says one should use web-dir and "" is only there for compatiblity reasons. Furthermore, it makes sense to move vendor/bin folders outside the document root.

helhum commented 7 years ago

you can set the web-dir to "" and achieve the same as before, right?

That is of course possible. One need to make sure however that the vendor dir is not accessible through the webserver.

Other than that, changing the web root is possible via command line by just:

composer config extra.typo3/cms.web-dir htdocs and after that doing a composer install

However even that is not straightforward if your root package has some files committed already (extensions in typo3conf/ext, LocalConfiguration.php, AdditionalConfiguration.php and maybe more)

Changing the web directory for the composer installer will of course not touch those files and you will end up with a broken installation. If take this into account, I don't see a way to implement something in the installer that is generic enough that it becomes useful. Please correct me if I'm wrong.

Besides that, I still think it is an edge case that it is not possible to set a web directory of your liking in different environments, especially for local development installations.

Especially, if I don't have much influence at the server, e.g. shared web server with only FTP access.

In such environments you more often than not only have one directory that is the document root, so you would have to use web-dir '' anyway. Even cheaper hosting providers nowadays have the possibility to influence the web root.

In any case, as pointed out above, one needs to take manual (individual) steps anyway when changing the TYPO3 web root. All this needs to be done in individual deployment steps (which can be automated from command line as pointed out above)

Do I still miss anything?

helhum commented 7 years ago

Also the README.md says one should use web-dir and "" is only there for compatiblity reasons. Furthermore, it makes sense to move vendor/bin folders outside the document root.

Of course. However there is no way around that having a dedicated web root add some extra requirements to your hosting environments. You need to decide yourself whether to go the simple or slightly more complicated but more secure way.

Again, I can't see how changing something in the installer can help with this decision in any way

AndreasA commented 7 years ago

As long as you don't remove the option to use '' for web-dir it is OK but I kinda thought that was deprecated? As long as that isn't the case it isn't that important. One just has to add vendor/bin to denied via web server to achieve nearly the same.

Using the command line change in regards to the web-dir would still result in a composer.lock hash mismatch, though that one can of course be ignored.

Of course, one solution is always to modify the necessary files oneself during deployment or really ensure that there is only one web-root used on all servers. Even if it isn't htdocs but e.g. the domain name as long as all use the domain name it should still be fine.

So as long as the possibility for web-dir: "" will not be removed the ticket can be closed.