1. Go to this page and download the library: Download technodelight/php-git 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/ */
technodelight / php-git example snippets
$git = new Technodelight\GitShell\Api(
new Technodelight\ShellExec\Exec('/usr/bin/env git')
);
// read git log entries
foreach ($git->log('develop', 'head') as $logEntry) {
// $logEntry is an instance of Technodelight\GitShell\LogEntry here
}
// create a branch
$git->createBranch('my-precious-branch'); // return is void, but will throw exception on error
// switch to a branch
$git->switchBranch('develop');
// list remotes, optionally verbose mode
$git->remotes(); // runs git remote, returns 'origin' for example
$git->remotes(true); // runs git remote -v, returns a Technodelight\GitShell\Remote instance
// show branches, with optional filter, optionally with remotes
$git->branches();
$git->branches('feature/'); // this uses grep command in the background
$git->branches('', true); // each call will return a Technodelight\GitShell\Branch instance with remote
// retrieve the current branch
$git->currentBranch(); // instance of Technodelight\GitShell\Branch will be returned
// find the top level directory for current directory
$git->topLevelDirectory(); // returns false if not in a git dir, a path (string) otherwise
// show git diff
$git->diff(); // Technodelight\GitShell\DiffEntry object for current changes
$git->diff('develop'); // changes since last commit on develop
composer
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.