Download the PHP package offline/gitelephant without Composer
On this page you can find all versions of the php package offline/gitelephant. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package gitelephant
GitElephant is an abstraction layer to manage your git repositories with php
This library officially supports git >= 1.8, older version are supported as well, but with some caveat.
How it works
GitElephant mostly rely on the git binary to retrieve information about the repository, read the output and create an OOP layer to interact with
Some parts are (or will be) implemented by reading directly inside the .git folder
The api is completely transparent to the end user. You don't have to worry about which method is used.
Requirements
- php >=
7.2
- *nix system with git installed
*For php 7.1
, please use GitElephant version 3.x
*For php 7.0
, please use GitElephant version 2.x
*For php 5.x
please use GitElephant version 1.x
This library is tested on linux, but it should work well with any unix system, as far as a git binary is available. For windows support, well.. if someone want to help?!
Installation
composer
To install GitElephant with composer you simply need to create a composer.json in your project root and add:
Then run
You have now GitElephant installed in vendor/cypresslab/gitelephant
And an handy autoload file to include in you project in vendor/autoload.php
How to use
By default GitElephant try to use the git binary on your system.
the Repository class is the main class where you can find every method you need...
Read repository
branches
tags
commits
remotes
status
If you build a GitElephant\Status\Status class, you will get a nice api for getting the actual state of the working tree and staging area.
all this methods returns a PhpCollection of StatusFile objects
a StatusFile instance has all the information about the tree node changes. File names (and new file names for renamed objects), index and working tree status, and also a "git style" description like: added to index or deleted in work tree
Manage repository
You could also use GitElephant to manage your git repositories via PHP.
Your web server user (like www-data) needs to have access to the folder of the git repository
Remote repositories
If you need to access remote repository you have to install the ssh2 extension and pass a new Caller to the repository. this is a new feature...consider this in a testing phase
A versioned tree of files
A git repository is a tree structure versioned in time. So if you need to represent a repository in a, let's say, web browser, you will need a tree representation of the repository, at a given point in history.
Tree class
The Tree class implements ArrayAccess, Countable and Iterator interfaces.
You can use it as an array of git objects.
A Object instance is a php representation of a node in a git tree
You can also pass a tree object to the repository to get its subtree
Diffs
If you want to check a Diff between two commits the Diff class comes in
The Diff class implements ArrayAccess, Countable and Iterator interfaces
You can iterate over DiffObject
A DiffObject is a class that implements ArrayAccess, Countable and Iterator interfaces. It represent a file, folder or submodule changed in the Diff.
Every DiffObject can have multiple chunks of changes. For example:
You can iterate over DiffObject to get DiffChunks. DiffChunks are the last steps of the Diff process, they are a collection of DiffChunkLine Objects
Testing
The library is fully tested with PHPUnit.
Go to the base library folder and install the dev dependencies with composer, and then run the phpunitt test suite
If you want to run the test suite you should have all the dependencies loaded.
Symfony
There is a GitElephantBundle to use this library inside a Symfony project.
Dependencies
for tests
Code style
GitElephant follows the:
Want to contribute?
You are my new hero!
Just remember:
- PSR coding standards
- add tests to everything you develop
- if you don't use gitflow, just remember to branch from "develop" and send your PR there. Please do not send pull requests on the master branch.
Author
Matteo Giachino (twitter)
Many thanks to all the contributors
Thanks
Many thanks to Linus and all those who have worked/contributed in any way to git. Because it's awesome!!! I can't imagine being a developer without it.
Logo design by Stefano Lodovico
All versions of gitelephant with dependencies
symfony/process Version ~2.0|~3.0|~4.0
symfony/filesystem Version ~2.0|~3.0|~4.0
symfony/finder Version ~2.0|~3.0|~4.0
phpcollection/phpcollection Version ~0.4