I am working on a PHP webapp. I have to publish it on a distributed version control system (git) but I am not sure wether if to publish the root directory of the project or the public_html folder.
The root folder contains composer-related files and configuration files.
Also, what are the best practices to include the config files, which have to be omitted/obscured from the version control?
The project is structured as follows:
+ root
|_ (...)
|_ config.php
|_ composer.json
|_ composer.lock
|_ public_html
|_ index.php
|_ (...) // The rest of the project
git isn't primarily about "publishing" anything, it's about tracking the changes to something, and having somewhere to retrieve particular versions.
It's probably easier to think about what not to put into version control:
config.php
should be committed without knowing what's in it - possibly it should be, but some of the things in it should be moved elsewhere.To not commit something, just list it in .gitignore
. (Note that this isn't a security measure, just convenience: it doesn't remove already committed files, even them from future revisions, nor does it prevent you adding them accidentally in future; it just makes most commands not default to adding them. You still have to pay attention to what you're committing.)
Everything else probably belongs in git, including composer.lock
.