Download the PHP package moonlitbc/gitelephant without Composer
On this page you can find all versions of the php package moonlitbc/gitelephant. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download moonlitbc/gitelephant
More information about moonlitbc/gitelephant
Files in moonlitbc/gitelephant
Package gitelephant
Short Description An abstraction layer for git written in PHP 5.3
License LGPL-3.0+
Homepage http://gitelephant.cypresslab.net/
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.
Watch a live example of what you can do with GitElephant, Symfony2 and a git repository...
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 >= 5.3.0
- *nix system with git installed
I work on linux, but the lib should work well with every unix system, as far as a git binary is available. I don't have a windows installation to test...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.
Symfony2
There is a GitElephantBundle to use this library inside a Symfony2 project.
Dependencies
for tests
Platform configuration
Code style
- GitElephant follows the PSR-2 Coding Standard
- I'm using gitflow
Want to contribute?
You are my new hero!
Just remember:
- PSR2 coding standard
- test everything you develop with phpunit
- 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 ~4.0
symfony/filesystem Version ~4.0
symfony/finder Version ~4.0
phpcollection/phpcollection Version ~0.4