This simple trick allows to retrieve GIT_ROOT or PROJECT_ROOT from anywhere within the project folder structure. Whenever it’s needed, just use this:
export GIT_ROOT=$(realpath $(git rev-parse --git-dir)/..)
cd $GIT_ROOT;
Software in theory and practice: tips, tricks n' philosophy
This simple trick allows to retrieve GIT_ROOT or PROJECT_ROOT from anywhere within the project folder structure. Whenever it’s needed, just use this:
export GIT_ROOT=$(realpath $(git rev-parse --git-dir)/..)
cd $GIT_ROOT;
This is a mindnote for myself. If someone else finds it useful, too == profit.
Because of MageFlow development I need to use quite a lot shell commands, for example ping.
Whenever exec, passthru or system returns code 127 check the path of the command. It means that the command cannot be found. It also means that PHP runs the command in such a shell that does not necessarily have PATH set properly and thus the command is not found.
Example
system('ping mygreathost.com', $retval);
$retval is 127.
Specify full path to ping command:
system('/bin/ping mygreathost.com', $retval);
$retval is 0 or 1 depending if mygreathost.com is available or not.