Support alternative matomo bootstrap file #14887
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Currently, we allow to put a
bootstrap.php
file into the root directory of Matomo and then load it as first thing. This allows for example the configuration of a few things that are needed to be set BEFORE we load any config. Such asThis works nicely. The problem is when you would like to use Matomo for example as a submodule, or install it through composer, etc... then having a file in Matomo directory doesn't do the trick and you need to have the bootstrap file outside the Matomo directory.
That's why I'm now looking for
../matomo_bootstrap.php
. It's not ideal cause what if the next person wants to have it at../../../matomo_bootstrap.php
etc. Ideally there be an environment variable. However, the project I'm working on I cannot make use of environment variables.I will try to workaround it by putting all files into a new endpoint like
my_index.php
which then includesmatomo_bootstrap.php
andmatomo/index.php
for example but likely this won't work since Matomo will then not know the correct paths anymore...Also we cannot look for
../bootstrap.php
btw since someone might actually use that file for a completely different project and we don't want to load any file by accident that does not belong to Matomo.Update: I couldn't find a workaround for this because otherwise Matomo gets completely confused with paths etc when embedding Matomo eg in a file
index.php
by doing likematomo/index.php
and as I can't use environment variables or anything else will need this solution. Also I noticed that with such a solution we risk that Matomo thinks it is uninstalled and this be a security issue. An attacker could install Matomo using the attacker's DB credentials and this way get super user access which allows to install plugins etc.