markwalet/laravel-git-state
Composer 安装命令:
composer require markwalet/laravel-git-state
包简介
A Laravel package that gives you information about the current git state.
README 文档
README
A Laravel package that gives you information about the current git state.
Installation
You can install this package with composer:
composer require markwalet/laravel-git-state
The package supports PHP 8.2+ and Laravel 12+.
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:
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 use MarkWalet\GitState\Drivers\GitDriver; class Controller { public function index(GitDriver $driver) { $branch = $driver->currentBranch(); $commit = $driver->latestCommitHash(); $timestamp = $driver->latestCommitTimestamp(); // Carbon instance $title = $driver->latestCommitTitle(); $description = $driver->latestCommitDescription(); return view('index', compact('branch', 'commit', 'timestamp', 'title', 'description')); } }
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 use MarkWalet\GitState\GitStateManager; class Controller { public function index(GitStateManager $driver) { $branch = $driver->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:
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.
markwalet/laravel-git-state 适用场景与选型建议
markwalet/laravel-git-state 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 112.75k 次下载、GitHub Stars 达 8, 最近一次更新时间为 2019 年 08 月 02 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 markwalet/laravel-git-state 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 markwalet/laravel-git-state 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 112.75k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 8
- 点击次数: 29
- 依赖项目数: 2
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2019-08-02