承接 ibrostudio/laravel-git 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

ibrostudio/laravel-git

Composer 安装命令:

composer require ibrostudio/laravel-git

包简介

Manage git repositories with Laravel

README 文档

README

A powerful Laravel package for managing Git repositories with an elegant, fluent API. This package provides a seamless integration between Laravel applications and Git repositories, allowing you to perform Git operations programmatically.

Presentation and Goal

Laravel Git is designed to simplify Git operations in Laravel applications. It provides a clean, object-oriented interface to interact with Git repositories, making it easy to:

  • Create, clone, and manage Git repositories
  • Perform common Git operations (pull, push, fetch, commit)
  • Work with branches, tags, and releases
  • Integrate with GitHub (and potentially other Git providers in the future)
  • Generate changelogs and manage versioning

The goal of this package is to provide a robust, Laravel-friendly way to interact with Git repositories, whether for deployment automation, version control management, or other Git-related tasks in your Laravel applications.

Requirements

  • PHP ^8.4
  • Laravel 12
  • Git

Installation

You can install the package via Composer:

composer require ibrostudio/laravel-git

The package will automatically register its service provider.

Configuration

Publish the configuration file:

php artisan vendor:publish --provider="IBroStudio\Git\GitServiceProvider"

This will create a config/git.php file where you can configure:

  • Default Git provider, branch, and remote
  • Authentication credentials for Git providers (GitHub)
  • Repository templates
  • Changelog configuration
  • Pre-commit hooks
  • Scripts for deployment, formatting, and testing

GitHub Authentication

To use GitHub integration, set your GitHub credentials in your .env file:

GITHUB_USERNAME=your-github-username
GITHUB_TOKEN=your-github-personal-access-token

Basic Usage

Opening an Existing Repository

use IBroStudio\Git\Repository;

// Open a repository from a local path
$repository = Repository::open('/path/to/repository');

Cloning a Repository

use IBroStudio\Git\Repository;

// Clone a repository
$repository = Repository::clone(
    url: 'git@github.com:username/repository.git',
    localParentDirectoryPath: '/path/to/parent/directory'
);

Creating a New Repository

use IBroStudio\Git\Repository;

$repository = Repository::init([
    'name' => 'new-repository',
    'localParentDirectory' => '/path/to/parent/directory',
]);

This will use all default values from git.php config file.

You can define more parameters and overwrite default values:

use IBroStudio\Git\Repository;
use IBroStudio\DataObjects\Enums\GitProvidersEnum;
use IBroStudio\Git\Dto\OwnerDto\AuthOwnerDto;
use IBroStudio\Git\Dto\RepositoryDto\ConfigDto\RemoteDto;
use IBroStudio\DataObjects\ValueObjects\GitSshUrl;
use IBroStudio\Git\Enums\GitRepositoryVisibilitiesEnum;

$repository = Repository::init([
    'name' => 'new-repository',
    'branch' => 'main',
    'owner' => AuthOwnerDto::from(['name' => 'your-github-username']),
    'provider' => GitProvidersEnum::GITHUB,
    'remote' => RemoteDto::from([
        'name' => 'origin',
        'url' => GitSshUrl::build(GitProvidersEnum::GITHUB, 'your-github-username', 'new-repository'),
    ]),
    'localParentDirectory' => '/path/to/parent/directory',
    'visibility' => GitRepositoryVisibilitiesEnum::PRIVATE,
]);

Basic Git Operations

// Check repository status
$status = $repository->status();
$hasChanges = $repository->hasChanges();

// Fetch, pull, and push
$repository->fetch();
$repository->pull();
$repository->push();

// Restore changes
$repository->restore();

Working with Commits

// Get the last commit
$lastCommit = $repository->commits()->last();

// Get commit history
$history = $repository->commits()->history();

// Create a new commit
use IBroStudio\Git\Dto\RepositoryDto\CommitDto;

$commit = CommitDto::from([
    'message' => 'Your commit message',
    'description' => 'Optional longer description',
]);

$repository->commits()->add($commit);

// Undo the last commit
$repository->commits()->undo();

Advanced Usage

Working with Branches

// Create a new branch
$repository->branches()->create('feature/new-feature');

// Switch to a branch
$repository->branches()->checkout('feature/new-feature');

// Merge branches
$repository->branches()->merge('feature/new-feature', 'main');

Working with Tags and Releases

// Create a tag
$repository->tags()->create('v1.0.0');

// Create a release
use IBroStudio\Git\Dto\RepositoryDto\ReleaseDto;

$release = ReleaseDto::from([
    'tag' => 'v1.0.0',
    'name' => 'Version 1.0.0',
    'description' => 'Release notes for version 1.0.0',
]);

$repository->releases()->create($release);

Generating Changelogs

$repository->changelog()->generate();

API Documentation

The package provides several main classes and interfaces:

  • Git: The main facade for interacting with Git providers
  • Repository: Represents a Git repository with methods for common operations
  • Commit: Represents a Git commit
  • Branch: Represents a Git branch
  • Tag: Represents a Git tag
  • Release: Represents a Git release

Each class provides a fluent interface for performing operations related to its domain.

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

License

The MIT License (MIT). Please see License File for more information.

ibrostudio/laravel-git 适用场景与选型建议

ibrostudio/laravel-git 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 15 次下载、GitHub Stars 达 1, 最近一次更新时间为 2024 年 10 月 02 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「git」 「laravel」 「iBroStudio」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 ibrostudio/laravel-git 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 ibrostudio/laravel-git 我们能提供哪些服务?
定制开发 / 二次开发

基于 ibrostudio/laravel-git 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 15
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 1
  • 点击次数: 6
  • 依赖项目数: 1
  • 推荐数: 0

GitHub 信息

  • Stars: 1
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2024-10-02