https://github.com/markwalet/laravel-git-state
A Laravel package that gives you information about the current git state.
https://github.com/markwalet/laravel-git-state
git laravel php php-package
Last synced: 4 months ago
JSON representation
A Laravel package that gives you information about the current git state.
- Host: GitHub
- URL: https://github.com/markwalet/laravel-git-state
- Owner: markwalet
- License: mit
- Created: 2019-08-02T14:22:24.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2025-01-31T14:33:11.000Z (10 months ago)
- Last Synced: 2025-06-09T11:09:23.938Z (5 months ago)
- Topics: git, laravel, php, php-package
- Language: PHP
- Size: 104 KB
- Stars: 7
- Watchers: 1
- Forks: 0
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Funding: .github/FUNDING.yml
- License: LICENSE.md
Awesome Lists containing this project
README
# Laravel Git State
[](LICENSE.md)
[](https://packagist.org/packages/markwalet/laravel-git-state)
[](https://github.com/markwalet/laravel-git-state/actions)
[](https://codecov.io/gh/markwalet/laravel-git-state)
[](https://packagist.org/packages/markwalet/laravel-git-state)
A Laravel package that gives you information about the current git state.
## Installation
You can install this package with composer:
```shell
composer require markwalet/laravel-git-state
```
Laravel auto-loads service providers for you, so you don't have to register it. If you want to register the service provider manually, add the following line to your `config/app.php` file:
```php
MarkWalet\GitState\GitStateServiceProvider::class
```
## Usage
When you want to get information about the current git state, you can inject the `MarkWalet\GitState\Drivers\GitDriver` class in your methods:
```php
currentBranch();
$commit = $driver->latestCommitHash();
return view('index', compact('branch', 'commit'));
}
}
```
When injecting a GitDriver like this, you will get an instance of the default driver you configured. If you want to have more control over the driver you are using, you can use the `MarkWalet\GitState\GitManager`:
```php
driver('other-driver')->currentBranch();
return view('index', compact('branch'));
}
}
```
## Configuration
The default configuration is defined in `git-state.php`. If you want to edit this file you can copy it to your config folder by using the following command:
```shell
php artisan vendor:publish --provider="MarkWalet\GitState\GitServiceProvider"
```
In this file you can configure different drivers for fetching the current Git state, as well as setting a default configuration.
The supported drivers are: `exec` and `file`. There is also a `fake` implementation for testing purposes.