git / git-bundle
GitHub-like git repository viewer for Symfony, powered by libgit2 via the php-git2 extension
Package info
gitlab.glitchr.dev/public-repository/agnostic/git
Type:symfony-bundle
pkg:composer/git/git-bundle
Requires
- php: ^8.1
- ext-git2: *
- symfony/config: ^6.0|^7.0|^8.0
- symfony/dependency-injection: ^6.0|^7.0|^8.0
- symfony/framework-bundle: ^6.0|^7.0|^8.0
- symfony/http-kernel: ^6.0|^7.0|^8.0
- symfony/routing: ^6.0|^7.0|^8.0
- symfony/twig-bundle: ^6.0|^7.0|^8.0
Requires (Dev)
- phpunit/phpunit: ^10.5
This package is auto-updated.
Last update: 2026-07-05 02:50:29 UTC
README
A GitHub-like, read-only git repository viewer embedded in your Symfony application — browse trees, blobs, commit history, diffs, branches and tags of any local repository from your own site, behind your own security layer.
Philosophy
- In-process, powered by libgit2. All repository reads go through
libgit2 via the php-git2
PHP extension. Requests never shell out to the
gitbinary and never talk to an external service (no gitweb/cgit/GitLab needed): a repository is treated as a plain data source, opened and object-read directly by PHP. - Read-only by construction. The bundle exposes lookups only (trees, blobs, commits, refs). Nothing writes to the repositories.
- Safe by object addressing. Paths in URLs are resolved through git tree objects, never through the filesystem — path traversal outside the repository is impossible by design. Every route is additionally gated by a configurable role.
- Repositories are declarative. You list repositories in config; anything
declared with a
urlwhosepathdoes not exist yet is cloned automatically duringcache:warmup, and fetched (--all --prune) on later warmups. Deploying a new viewer is: add 4 lines of YAML, warm the cache.
Try it in one command
A self-contained demo (bare Symfony skeleton + this bundle, browsing the libgit2 repository itself) ships in example/Dockerfile:
docker build -t git-bundle-demo -f example/Dockerfile .
docker run --rm -p 8000:8000 git-bundle-demo
# → http://localhost:8000/git (libgit2 is auto-cloned at startup by the warmer)
Requirements
- PHP ≥ 8.1
The php-git2 extension (PHP bindings for the libgit2 C library). It is not bundled with PHP; install libgit2 then build the extension:
apt install libgit2-dev # or brew install libgit2 git clone https://github.com/RogerGee/php-git2 && cd php-git2 phpize && ./configure --with-libgit2=/usr && make && make install docker-php-ext-enable git2 # or add "extension=git2.so" to php.ini
Installation
composer require git/git-bundle:^1.0
Enable it (Flex usually does this) in config/bundles.php:
Git\GitBundle::class => ['all' => true],
Configuration
config/packages/git.yaml:
git:
route_prefix: /git # URL prefix for all viewer routes
access_role: ROLE_ADMIN # role required to browse (PUBLIC_ACCESS to open up)
repositories:
hellogitworld:
url: 'https://github.com/githubtraining/hellogitworld' # auto-cloned at cache:warmup
path: '%kernel.project_dir%/var/repos/hellogitworld.git'
label: 'Hello Git World'
description: 'Demo repository'
default_branch: master
app:
path: '%kernel.project_dir%' # any existing local repo works too
label: 'This application'
default_branch: HEAD
Routing: on Symfony ≥ 7.3 the controller's attribute routes are registered
automatically (the URL prefix comes from git.route_prefix via a class-level
#[Route]). On older versions import them once in config/routes/git.yaml:
git:
resource: '@GitBundle/Resources/config/routes.php'
Do not add an import prefix: — the routes are already prefixed.
Routes
| URL | View |
|---|---|
/git | repository index |
/git/{repo} | redirect to the default branch tree |
/git/{repo}/tree/{ref}/{path} | directory listing |
/git/{repo}/blob/{ref}/{path} | file contents |
/git/{repo}/log/{ref} | commit history (paginated) |
/git/{repo}/commit/{sha} | commit details + diff |
/git/{repo}/branches, /git/{repo}/tags | refs |
Notes
- The auto-clone/fetch happens in a cache warmer (
RepositoryWarmer, optional): a slow remote can slow downcache:warmup, so prefer bare mirrors on fast storage for large repositories. - Licensed LGPL-3.0-or-later (see
COPYING/COPYING.LESSER).