PHPackages                             jeffersongoncalves/laravel-zero-git - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [CLI &amp; Console](/categories/cli)
4. /
5. jeffersongoncalves/laravel-zero-git

ActiveLibrary[CLI &amp; Console](/categories/cli)

jeffersongoncalves/laravel-zero-git
===================================

Detect the current repository from the git remote: parse SSH/HTTPS remote URLs into host/owner/repo and build a stable slug, used by CLIs that auto-detect their workspace/repo.

v1.0.0(today)10MITPHPPHP ^8.2CI passing

Since Jun 23Pushed today1 watchersCompare

[ Source](https://github.com/jeffersongoncalves/laravel-zero-git)[ Packagist](https://packagist.org/packages/jeffersongoncalves/laravel-zero-git)[ Docs](https://github.com/jeffersongoncalves/laravel-zero-git)[ RSS](/packages/jeffersongoncalves-laravel-zero-git/feed)WikiDiscussions main Synced today

READMEChangelog (1)Dependencies (3)Versions (2)Used By (0)

[![laravel-zero-git](https://raw.githubusercontent.com/jeffersongoncalves/laravel-zero-git/main/art/jeffersongoncalves-laravel-zero-git.png)](https://raw.githubusercontent.com/jeffersongoncalves/laravel-zero-git/main/art/jeffersongoncalves-laravel-zero-git.png)

laravel-zero-git
================

[](#laravel-zero-git)

Detect the current repository from its git remote. This package parses SSH and HTTPS remote URLs into `host` / `owner` / `repo`, builds a stable slug, and can read the remote of a working directory directly from git.

It is used by Laravel Zero CLIs (such as Bitbucket / Jira tools) that auto-detect their workspace and repository from the local git checkout.

Why
---

[](#why)

CLIs that operate on "the current repo" need a reliable way to turn a git remote URL into structured data, regardless of whether the remote is an SSH or HTTPS URL, with or without a `.git` suffix, with or without embedded credentials or a port. This package centralizes that parsing in one tested, framework-free place.

Installation
------------

[](#installation)

```
composer require jeffersongoncalves/laravel-zero-git
```

Requires PHP `^8.2`. No other dependencies.

Usage
-----

[](#usage)

### Parse a remote URL

[](#parse-a-remote-url)

```
use JeffersonGoncalves\LaravelZero\Git\GitRemoteParser;

$info = GitRemoteParser::parse('git@github.com:acme/widgets.git');

$info->host;       // "github.com"
$info->owner;      // "acme"
$info->repo;       // "widgets"
$info->fullName(); // "acme/widgets"

GitRemoteParser::parse('not a url'); // null
```

Supported shapes:

- `git@host:owner/repo.git` (SSH scp-like)
- `ssh://git@host:port/owner/repo.git`
- `https://host/owner/repo` (with or without `.git`, with or without `user@`)

### Build a stable slug

[](#build-a-stable-slug)

```
GitRemoteParser::slug('git@github.com:Acme/Widgets.git'); // "acme-widgets"
```

The slug is a lowercased, sanitized `owner-repo` string, suitable as a stable key for per-repository config files.

### Resolve from the current checkout

[](#resolve-from-the-current-checkout)

```
use JeffersonGoncalves\LaravelZero\Git\RepositoryResolver;

$resolver = new RepositoryResolver(); // current working directory
$info = $resolver->resolve();         // RemoteInfo|null (reads `origin`)

$resolver->resolve('upstream');       // a different remote
$resolver->currentRemoteUrl();        // the raw URL string, or null

// Point it at a specific directory:
$resolver = new RepositoryResolver('/path/to/repo');
```

`resolve()` and `currentRemoteUrl()` return `null` when the directory is not a git repository or the remote does not exist / cannot be parsed.

Public classes
--------------

[](#public-classes)

ClassPurpose`JeffersonGoncalves\LaravelZero\Git\RemoteInfo`Readonly DTO: `host`, `owner`, `repo`, `fullName()``JeffersonGoncalves\LaravelZero\Git\GitRemoteParser``parse(string): ?RemoteInfo`, `slug(string): ?string``JeffersonGoncalves\LaravelZero\Git\RepositoryResolver``resolve(?string): ?RemoteInfo`, `currentRemoteUrl(?string): ?string`License
-------

[](#license)

MIT. See [LICENSE](LICENSE).

###  Health Score

40

—

FairBetter than 86% of packages

Maintenance100

Actively maintained with recent releases

Popularity2

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity45

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 75% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

0d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/411493?v=4)[Jefferson Gonçalves](/maintainers/jeffersongoncalves)[@jeffersongoncalves](https://github.com/jeffersongoncalves)

---

Top Contributors

[![jeffersongoncalves](https://avatars.githubusercontent.com/u/411493?v=4)](https://github.com/jeffersongoncalves "jeffersongoncalves (3 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (1 commits)")

---

Tags

clicomposergitgit-remotejeffersongoncalveslaravel-zerophpslugslugclilaravel-zerogitremoterepository

###  Code Quality

TestsPest

Code StyleLaravel Pint

### Embed Badge

![Health badge](/badges/jeffersongoncalves-laravel-zero-git/health.svg)

```
[![Health](https://phpackages.com/badges/jeffersongoncalves-laravel-zero-git/health.svg)](https://phpackages.com/packages/jeffersongoncalves-laravel-zero-git)
```

###  Alternatives

[nunomaduro/collision

Cli error handling for console/command-line PHP applications.

4.6k348.7M10.4k](/packages/nunomaduro-collision)[nunomaduro/laravel-console-menu

Laravel Console Menu is an output method for your Laravel/Laravel Zero commands.

815424.6k52](/packages/nunomaduro-laravel-console-menu)[nunomaduro/laravel-console-task

Laravel Console Task is a output method for your Laravel/Laravel Zero commands.

2592.3M13](/packages/nunomaduro-laravel-console-task)[projektgopher/whisky

A simple CLI tool for managing a project's git hooks across multiple members.

242337.0k21](/packages/projektgopher-whisky)[nunomaduro/laravel-console-summary

A Beautiful Laravel Console Summary for your Laravel/Laravel Zero commands.

672.2M4](/packages/nunomaduro-laravel-console-summary)[guanguans/ai-commit

Automagically generate conventional git commit message with AI. - 使用 AI 自动生成约定式 git 提交信息。

39331.4k10](/packages/guanguans-ai-commit)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
