1. Go to this page and download the library: Download symplify/git-wrapper library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
symplify / git-wrapper example snippets
use Symplify\GitWrapper\GitWrapper;
// Initialize the library. If the path to the Git binary is not passed as
// the first argument when instantiating GitWrapper, it is auto-discovered.
/path/to/working/copy`, get a working copy object
$git = $gitWrapper->cloneRepository('git://github.com/symplify/git-wrapper.git', __DIR__ . '/path/to/working/copy');
// Create a file in the working copy
touch(__DIR__ . '/path/to/working/copy/text.txt');
// Add it, commit it, and push the change
$git->add(__DIR__ . '/test.txt');
$git->commit('Added the test.txt file as per the examples.');
$git->push();
// Render the output for operation
echo $git->push();
// Stream output of subsequent Git commands in real time to STDOUT and STDERR.
$gitWrapper->streamOutput();
// Execute an arbitrary git command.
// The following is synonymous with `git config -l`
$gitWrapper->git('config -l');
use Monolog\Handler\StreamHandler;
use Monolog\Logger;
use Symplify\GitWrapper\EventSubscriber\GitLoggerEventSubscriber;
// Log to a file named "git.log"
$logger = new Logger('git');
$logger->pushHandler(new StreamHandler('git.log', Logger::DEBUG));
// Instantiate the subscriber, add the logger to it, and register it.
$gitWrapper->addLoggerEventSubscriber(new GitLoggerEventSubscriber($logger));
$git = $gitWrapper->cloneRepository('git://github.com/symplify/git-wrapper.git', '/path/to/working/copy');
// The "git.log" file now has info about the command that was executed above.