Skip to content

Instantly share code, notes, and snippets.

@codeZoner
Last active April 12, 2022 19:48
Show Gist options
  • Select an option

  • Save codeZoner/6545d76cc0b5b80d9d8e76fb3a60cd1d to your computer and use it in GitHub Desktop.

Select an option

Save codeZoner/6545d76cc0b5b80d9d8e76fb3a60cd1d to your computer and use it in GitHub Desktop.
Execute Shell Script using PHP (Git Pull Example)
<?php
$old_path = getcwd();
chdir('/path/to/file');
$output = shell_exec('./shell-script.sh');
chdir($old_path);
echo $output;
?>
#!/bin/bash
cd /path/to/git/folder && git pull origin branch_name
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment